Пример #1
0
        public async Task ShowVideo(
            string mediaItemFilePath,
            ScreenPosition screenPosition,
            Guid mediaItemId,
            TimeSpan startOffset,
            bool startFromPaused)
        {
            _mediaItemId   = mediaItemId;
            _startPosition = startOffset;
            _lastPosition  = TimeSpan.Zero;

            ScreenPositionHelper.SetScreenPosition(_mediaElement.FrameworkElement, screenPosition);

            if (startFromPaused)
            {
                _mediaElement.Position = _startPosition;
                await _mediaElement.Play();

                OnMediaChangeEvent(new MediaEventArgs {
                    MediaItemId = _mediaItemId, Change = MediaChange.Started
                });
            }
            else
            {
                OnMediaChangeEvent(new MediaEventArgs {
                    MediaItemId = _mediaItemId, Change = MediaChange.Starting
                });
                _mediaElement.Source = new Uri(mediaItemFilePath);
            }
        }
Пример #2
0
        public void ShowWeb(
            string mediaItemFilePath,
            Guid mediaItemId,
            int pdfStartingPage,
            PdfViewStyle pdfViewStyle,
            bool showMirror,
            ScreenPosition screenPosition)
        {
            _useMirror = showMirror;

            if (string.IsNullOrEmpty(mediaItemFilePath))
            {
                return;
            }

            _showing     = false;
            _mediaItemId = mediaItemId;

            ScreenPositionHelper.SetScreenPosition(_browserGrid, screenPosition);

            OnMediaChangeEvent(CreateMediaEventArgs(mediaItemId, MediaChange.Starting));

            string?webAddress;

            if (Path.GetExtension(mediaItemFilePath).Equals(".pdf", StringComparison.OrdinalIgnoreCase))
            {
                // https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

                var viewString        = GetPdfViewString(pdfViewStyle);
                var cacheBusterString = DateTime.Now.Ticks.ToString();

                webAddress = $"pdf://{mediaItemFilePath}?t={cacheBusterString}#view={viewString}&page={pdfStartingPage}";
            }
            else
            {
                var urlHelper = new WebShortcutHelper(mediaItemFilePath);
                webAddress = urlHelper.Uri;
            }

            _currentMediaItemUrl = webAddress;

            RemoveAnimation();

            _browserGrid.Visibility = Visibility.Visible;

            _browser.Load(webAddress);
        }
Пример #3
0
        public async Task ShowVideoOrPlayAudio(
            string mediaItemFilePath,
            ScreenPosition screenPosition,
            Guid mediaItemId,
            MediaClassification mediaClassification,
            TimeSpan startOffset,
            bool startFromPaused)
        {
            _mediaItemId       = mediaItemId;
            _mediaItemFilePath = mediaItemFilePath;

            Log.Debug($"ShowVideoOrPlayAudio - Media Id = {_mediaItemId}");

            _mediaClassification = mediaClassification;
            _startPosition       = startOffset;
            _lastPosition        = TimeSpan.Zero;

            ScreenPositionHelper.SetScreenPosition(_mediaElement.FrameworkElement, screenPosition);
            ScreenPositionHelper.SetSubtitleBlockScreenPosition(_subtitleBlock, screenPosition);

            _mediaElement.MediaItemId = mediaItemId;

            if (startFromPaused)
            {
                _mediaElement.Position = _startPosition;
                await _mediaElement.Play(new Uri(mediaItemFilePath), _mediaClassification);

                OnMediaChangeEvent(CreateMediaEventArgs(_mediaItemId, MediaChange.Started));

                await CreateSubtitleProvider(mediaItemFilePath, startOffset);
            }
            else
            {
                Log.Debug($"Firing Started - Media Id = {_mediaItemId}");

                await CreateSubtitleFile(mediaItemFilePath);

                await _mediaElement.Play(new Uri(mediaItemFilePath), _mediaClassification).ConfigureAwait(true);

                OnMediaChangeEvent(CreateMediaEventArgs(_mediaItemId, MediaChange.Starting));
            }
        }
Пример #4
0
        private void ShowImageInternal(
            bool isBlankScreenImage,
            ScreenPosition screenPosition,
            string imageFile,
            Image controlToUse,
            Image otherControl,
            ImageFadeType fadeType,
            double fadeTime,
            Action hideCompleted,
            Action showCompleted)
        {
            controlToUse.SetValue(Panel.ZIndexProperty, 1);
            otherControl.SetValue(Panel.ZIndexProperty, 0);

            controlToUse.Stretch = isBlankScreenImage
                ? Stretch.Fill
                : Stretch.Uniform;

            ScreenPositionHelper.SetScreenPosition(
                controlToUse,
                isBlankScreenImage ? new ScreenPosition() : screenPosition);

            if (fadeType == ImageFadeType.CrossFade ||
                fadeType == ImageFadeType.None)
            {
                ShowImageInControl(imageFile, controlToUse, fadeType, fadeTime, showCompleted);
                HideImageInControl(otherControl, fadeType, fadeTime, hideCompleted);
            }
            else
            {
                HideImageInControl(
                    otherControl,
                    fadeType,
                    fadeTime,
                    () =>
                {
                    hideCompleted?.Invoke();
                    ShowImageInControl(imageFile, controlToUse, fadeType, fadeTime, showCompleted);
                });
            }
        }
Пример #5
0
        public void ShowWeb(
            string mediaItemFilePath,
            Guid mediaItemId,
            bool showMirror,
            ScreenPosition screenPosition)
        {
            _useMirror = showMirror;

            if (string.IsNullOrEmpty(mediaItemFilePath))
            {
                return;
            }

            _showing     = false;
            _mediaItemId = mediaItemId;

            ScreenPositionHelper.SetScreenPosition(_browserGrid, screenPosition);

            OnMediaChangeEvent(CreateMediaEventArgs(mediaItemId, MediaChange.Starting));

            string webAddress;

            if (Path.GetExtension(mediaItemFilePath).Equals(".pdf", StringComparison.OrdinalIgnoreCase))
            {
                webAddress = $"pdf://{mediaItemFilePath}";
            }
            else
            {
                var urlHelper = new WebShortcutHelper(mediaItemFilePath);
                webAddress = urlHelper.Uri;
            }

            _currentMediaItemUrl = webAddress;

            RemoveAnimation();

            _browserGrid.Visibility = Visibility.Visible;

            _browser.Load(webAddress);
        }