public MediaPlayerAPI(YouTubeMediaElement element, int elementId)
 {
     element.ThrowIfArgumentNull("Failed to create MediaPlayer API JsonRpc service object because media element was null");
     LogTo.Debug($"Loading MediaPlayer API JsonRpc service for YouTube id {element.Id} element id {elementId}");
     this.ExpectedElementId   = elementId;
     this.CurrentMediaElement = element;
 }
コード例 #2
0
 public MpvPlayerWindow(YouTubeMediaElement element, int elementId)
 {
     element.ThrowIfArgumentNull("Failed to open Mpv Player Window because media element is null");
     Element = element;
     API     = new MediaPlayerAPI(element, elementId);
     Server.RegisterService(API);
     BeginMpvProcess();
 }
コード例 #3
0
        private void OpenElement(YouTubeMediaElement ivElem, int elementId)
        {
            if (ivElem == null)
            {
                return;
            }

            LastElement = ivElem;

            CreateVideoWindow(ivElem, elementId);
        }
コード例 #4
0
        public void OnElementChanged(IElement newElem,
                                     IControlHtml ctrlHtml)
        {
            // PlayerWindow?.CancelSave();

            if (newElem == null)
            {
                return;
            }

            if (LastElement?.ElementId == newElem.Id)
            {
                return;
            }

            var html = ctrlHtml?.Text ?? string.Empty;

            var ytEl = newElem.Type == ElementType.Topic
              ? YouTubeMediaElement.TryReadElement(html, newElem.Id)
              : null;

            bool noNewElem  = ytEl == null;
            bool noLastElem = LastElement == null || (Svc.SM.Registry.Element[LastElement.ElementId]?.Deleted ?? true);

            if (noNewElem && noLastElem)
            {
                return;
            }

            bool close = LastElement != null && ytEl == null;

            CloseElement();

            OpenElement(ytEl, newElem.Id);

            if (close)
            {
                PlayerWindow?.Close();
            }
        }
コード例 #5
0
        public async void ImportYouTubeVideo()
        {
            if (await ImportSemaphore.WaitAsync(0) == false)
            {
                return;
            }

            var res = await Application.Current.Dispatcher.Invoke(() =>
            {
                return(Show.Window().For(new Prompt <string> {
                    Message = "YouTube Id or Url:"
                }));
            });

            string idOrUrl = res.Model.Value;

            if (!string.IsNullOrWhiteSpace(idOrUrl))
            {
                await YouTubeMediaElement.Create(idOrUrl);
            }

            ImportSemaphore.Release();
        }
コード例 #6
0
 private void CreateVideoWindow(YouTubeMediaElement el, int elementId)
 {
     PlayerWindow             = new MpvPlayerWindow(el, elementId);
     PlayerWindow.API.Closed += VideoWindow_Closed;
 }