public CefYoutubeController()
        {
            InitializeComponent();
            WebBrowser.Address = @"custom://cefsharp/CefPlayer.html";
            //set startup value for Player
            WebBrowser.LoadingStateChanged += CheckkIfLoadingDone;

            var boundAsync = new BoundObject();

            boundAsync.PlayerLoadingDone    += JavascriptReady;
            boundAsync.PlayerPlayingChanged += BoundOnPlayerPlayingChanged;

            WebBrowser.JavascriptObjectRepository.Register("boundAsync", boundAsync, true);

            WebBrowser.JavascriptObjectRepository.ObjectBoundInJavascript += (sender, e) =>
            {
                var name = e.ObjectName;

                Console.WriteLine($"Object {e.ObjectName} was bound successfully.");
            };

            StartCommand = new Command(Start);
            StopCommand  = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam));
            PauseCommand = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam));
        }
Beispiel #2
0
        public CefYoutubeController()
        {
            InitializeComponent();
            WebBrowser.Address = @"custom://cefsharp/CefPlayer.html";
            //set startup value for Player
            WebBrowser.LoadingStateChanged += CheckkIfLoadingDone;
            var bound = new BoundObject();

            bound.PlayerLoadingDone    += JavascriptReady;
            bound.PlayerPlayingChanged += BoundOnPlayerPlayingChanged;
            WebBrowser.RegisterJsObject("bound", bound);

            StartCommand = new Command(Start);
            StopCommand  = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", stopVideoParam));
            PauseCommand = new Command(() => WebBrowser.ExecuteScriptAsync("setPlayerState", pausetVideoParam));
        }