Пример #1
0
        public void SwitchToRemotePlayback()
        {
            avp.Pause();
            CreateMediaInfo();
            mLocation = PlaybackLocation.REMOTE;

            //ios sample does it via queue, we'll straight up load
            var castSession = CastContext.SharedInstance.SessionManager.CurrentCastSession;
            RemoteMediaClient remoteMediaClient = null;
            var options = new MediaLoadOptions();

            //options.PlayPosition = currentprogress;
            options.Autoplay = true;

            if (castSession != null)
            {
                remoteMediaClient = castSession.RemoteMediaClient;
                remoteMediaClient.MediaQueue?.Clear();
            }

            if (castSession != null && remoteMediaClient != null && castMediaInfo != null)
            {
                remoteMediaClient.LoadMedia(castMediaInfo, options);
            }
            else
            {
                Console.WriteLine("ERROR in SwitchToRemotePlayback");
            }

            ClosePage();
        }
        public void SetupRemoteMediaClientWithMediaInfo()
        {
            // Don't load media if the video is what is already playing
            // or if we couldn't find a suitable source for the video
            if (didContinueCurrentVideo || suitableSourceNotFound)
            {
                return;
            }

            if (gcmDelegate == null)
            {
                return;
            }

            var currentprogress    = currentProgress;
            var playbackcontroller = gcmDelegate.playbackController;

            if (playbackcontroller == null)
            {
                return;
            }
            var options = new MediaLoadOptions();

            options.PlayPosition = currentprogress;
            options.Autoplay     = playbackcontroller.AutoPlay;

            var castSession = CastContext.SharedInstance.SessionManager.CurrentSession;
            RemoteMediaClient remoteMediaClient = null;

            if (castSession != null)
            {
                remoteMediaClient = castSession.RemoteMediaClient;
            }
            if (castSession != null && remoteMediaClient != null && castMediaInfo != null)
            {
                remoteMediaClient.LoadMedia(castMediaInfo, options);
            }
            else
            {
                Console.WriteLine("ERROR in SetupRemoteMediaClientWithMediaInfo");
            }
        }