Exemplo n.º 1
0
        public AudioPlayerViewModel()
        {
            mediaPlayer = CrossMediaManager.Current;

            MediaPlayer.StatusChanged += (sender, e) =>
            {
                RaisePropertyChanged(() => Status);
                RaisePropertyChanged(() => Position);
            };

            MediaPlayer.PlayingChanged += (sender, e) =>
            {
                RaisePropertyChanged(() => Position);
            };

            MediaPlayer.MediaQueue.QueueMediaChanged += (q_sender, q_e) =>
            {
                RaisePropertyChanged(() => PlayingText);
                if (CurrentTrack != null)
                {
                    CurrentTrack.MetadataUpdated += (m_sender, m_e) =>
                    {
                        RaisePropertyChanged(() => PlayingText);
                    };
                }
            };

            PlayPauseCommand    = new MvxAsyncCommand(async() => await PlaybackController.PlayPause());
            SkipPreviousCommand = new MvxAsyncCommand(async() => await PlaybackController.PlayPreviousOrSeekToStart());
            SkipNextCommand     = new MvxAsyncCommand(async() => await PlaybackController.PlayNext());
        }
Exemplo n.º 2
0
 private async void HandleNotificationActions(object sender, string action)
 {
     if (action.Equals(MediaServiceBase.ActionPlay))
     {
         await PlaybackController.Play();
     }
     else if (action.Equals(MediaServiceBase.ActionPause))
     {
         await PlaybackController.Pause();
     }
     else if (action.Equals(MediaServiceBase.ActionPrevious))
     {
         await PlaybackController.PlayPreviousOrSeekToStart();
     }
     else if (action.Equals(MediaServiceBase.ActionNext))
     {
         await PlaybackController.PlayNext();
     }
     else if (action.Equals(MediaServiceBase.ActionStop))
     {
         await Stop();
     }
 }