Example #1
0
        private void OnPlaybackStateChanged(MediaPlaybackSession sender, object args)
        {
            if (sender.PlaybackState == MediaPlaybackState.Playing && sender.PlaybackRate != _playbackRate)
            {
                sender.PlaybackRate = _playbackRate;
            }

            switch (sender.PlaybackState)
            {
            case MediaPlaybackState.Playing:
                _transport.PlaybackStatus = MediaPlaybackStatus.Playing;
                break;

            case MediaPlaybackState.Paused:
                _transport.PlaybackStatus = MediaPlaybackStatus.Paused;
                break;

            case MediaPlaybackState.None:
                _transport.PlaybackStatus = MediaPlaybackStatus.Stopped;
                break;
            }

            //else if (sender.PlaybackState == MediaPlaybackState.Paused && sender.Position == sender.NaturalDuration && _playlist.CurrentItem == _playlist.Items.LastOrDefault())
            //{
            //    Clear();
            //}
            //else
            //{
            //    Debugger.Break();
            //}

            PlaybackStateChanged?.Invoke(this, args);
        }
Example #2
0
 private void PlaybackSession_PlaybackStateChanged(MediaPlaybackSession sender, object args)
 {
     // This event is triggered by the media player object running in a background thread.
     // The dispatcher is required to avoid exceptions when this event is used by other
     // viewmodels to update bindable properties. We assume an instance of this service will
     // always be created on a UI thread (from code behind), so we use a dispatcher queue.
     _dispatcherQueue.TryEnqueue(() => PlaybackStateChanged?.Invoke(this, PlaybackState));
 }
Example #3
0
 protected virtual async void OnPlaybackStateChanged(MediaPlayerState state)
 {
     await DispatcherHelper.RunAsync(
         () =>
     {
         PlaybackStateChanged?.Invoke(this, new PlaybackStateEventArgs(state));
     });
 }
Example #4
0
 public void Play()
 {
     if (Instance.Skip)
     {
         reader.CurrentTime = reader.TotalTime - TimeSpan.FromMilliseconds(1000);
     }
     output.Play();
     PlaybackStateChanged?.Invoke(this, new EventArgs());
 }
Example #5
0
 protected void CurrentStateChanged()
 {
     if (IsPlaying)
     {
         _progressHandle.Start();
     }
     else
     {
         _progressHandle.Stop();
     }
     OnPropertyChanged("IsPlaying");
     OnPropertyChanged("CurrentState");
     PlayStateChanged?.Invoke(this, EventArgs.Empty);
     PlaybackStateChanged?.Invoke(this, new PlayStateChangedEventArgs(CurrentState));
 }
Example #6
0
 public void Pause()
 {
     output.Pause();
     PlaybackStateChanged?.Invoke(this, new EventArgs());
 }
Example #7
0
 private void Wasapi_PlaybackStopped(object sender, StoppedEventArgs e)
 {
     PlaybackStateChanged?.Invoke(this, e);
 }
Example #8
0
 public void FirePlaybackStateChanged(object sender, bool isPlaying)
 {
     PlaybackStateChanged?.Invoke(sender, isPlaying);
 }
Example #9
0
 private void MediaPlayer_ActiveSongChanged(object sender, EventArgs e)
 {
     PlaybackStateChanged?.Invoke(this);
 }
 private void OnPlaybackStateChanged(PlaybackState state)
 {
     App.DebugLog(state.ToString());
     PlaybackStateChanged?.Invoke(this, new PlaybackStateEventArgs(state));
 }