Beispiel #1
0
        public MediaPlayer()
        {
            StartCommand = new AsyncValueCommand(async() =>
            {
                if (State == PlaybackState.Playing)
                {
                    Pause();
                }
                else
                {
                    await Start();
                }
            }, allowsMultipleExecutions: false);

            FastForwardCommand = new AsyncCommand(async() =>
            {
                if (State != PlaybackState.Stopped)
                {
                    await Seek(Math.Min(Position + 5000, Duration));
                }
            }, _ => State != PlaybackState.Stopped, allowsMultipleExecutions: false);

            RewindCommand = new AsyncCommand(async() =>
            {
                if (State != PlaybackState.Stopped)
                {
                    await Seek(Math.Max(Position - 5000, 0));
                }
            }, _ => State != PlaybackState.Stopped, allowsMultipleExecutions: false);

            mediaPlayer = new MediaPlayerImplementation();
            mediaPlayer.UpdateStreamInfo         += OnUpdateStreamInfo;
            mediaPlayer.PlaybackCompleted        += SendPlaybackCompleted;
            mediaPlayer.PlaybackStarted          += SendPlaybackStarted;
            mediaPlayer.PlaybackPaused           += SendPlaybackPaused;
            mediaPlayer.PlaybackStopped          += SendPlaybackStopped;
            mediaPlayer.BufferingProgressUpdated += OnUpdateBufferingProgress;
            mediaPlayer.ErrorOccurred            += OnErrorOccurred;
            mediaPlayer.UsesEmbeddingControls     = true;
            mediaPlayer.Volume     = 1f;
            mediaPlayer.AspectMode = DisplayAspectMode.AspectFit;
            mediaPlayer.AutoPlay   = false;
            mediaPlayer.AutoStop   = true;

            controlsAlwaysVisible = false;
            controls = new Lazy <View>(() => mediaPlayer.GetEmbeddingControlView(this));
        }
Beispiel #2
0
        public MediaPlayer()
        {
            _impl = new MediaPlayerImpl();
            _impl.UpdateStreamInfo         += OnUpdateStreamInfo;
            _impl.PlaybackCompleted        += SendPlaybackCompleted;
            _impl.PlaybackStarted          += SendPlaybackStarted;
            _impl.PlaybackPaused           += SendPlaybackPaused;
            _impl.PlaybackStopped          += SendPlaybackStopped;
            _impl.BufferingProgressUpdated += OnUpdateBufferingProgress;
            _impl.ErrorOccurred            += OnErrorOccurred;
            _impl.UsesEmbeddingControls     = true;
            _impl.Volume     = 1d;
            _impl.AspectMode = DisplayAspectMode.AspectFit;
            _impl.AutoPlay   = false;
            _impl.AutoStop   = true;

            _controlsAlwaysVisible = false;
            _controls = new Lazy <View>(() =>
            {
                return(_impl.GetEmbeddingControlView(this));
            });
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the MediaPlayer class.
        /// </summary>
        public MediaPlayer()
        {
            _impl = DependencyService.Get <IPlatformMediaPlayer>(fetchTarget: DependencyFetchTarget.NewInstance);
            if (_impl != null)
            {
                _impl.UpdateStreamInfo         += OnUpdateStreamInfo;
                _impl.PlaybackCompleted        += SendPlaybackCompleted;
                _impl.PlaybackStarted          += SendPlaybackStarted;
                _impl.PlaybackPaused           += SendPlaybackPaused;
                _impl.PlaybackStopped          += SendPlaybackStopped;
                _impl.BufferingProgressUpdated += OnUpdateBufferingProgress;
                _impl.UsesEmbeddingControls     = true;
                _impl.Volume     = 1d;
                _impl.AspectMode = DisplayAspectMode.AspectFit;
                _impl.AutoPlay   = false;
                _impl.AutoStop   = true;

                _controlsAlwaysVisible = false;
                _controls = new Lazy <View>(() =>
                {
                    return(_impl.GetEmbeddingControlView(this));
                });
            }
        }
 /// <summary>
 /// Initializes a new instance of the MediaPlayer class.
 /// </summary>
 public MediaPlayer()
 {
     _impl = CreateMediaPlayerImpl();
     _impl.UpdateStreamInfo         += OnUpdateStreamInfo;
     _impl.PlaybackCompleted        += SendPlaybackCompleted;
     _impl.PlaybackStarted          += SendPlaybackStarted;
     _impl.PlaybackPaused           += SendPlaybackPaused;
     _impl.PlaybackStopped          += SendPlaybackStopped;
     _impl.BufferingProgressUpdated += OnUpdateBufferingProgress;
     _impl.UsesEmbeddingControls     = true;
     _impl.Volume           = 1d;
     _impl.AspectMode       = DisplayAspectMode.AspectFit;
     _impl.AutoPlay         = false;
     _impl.AutoStop         = true;
     _impl.IsLooping        = false;
     _controlsAlwaysVisible = false;
     _controls = new Lazy <View>(() =>
     {
         return(new EmbeddingControls
         {
             BindingContext = this
         });
     });
 }