What's the difference between BufferingStarted and PlaybackSession.BufferingStarted

I'm using UWP MediaPlayerElement, and set

var mediaPlayer = new MediaPlayer();
viuMediaPlayer.SetMediaPlayer(mediaPlayer);
mediaPlayer.BufferingStarted += MediaPlayer_BufferingStarted;
mediaPlayer.PlaybackSession.BufferingStarted += PlaybackSession_BufferingStarted;

When using BufferingStarted event, I found this two both have buffer start event. Simalarly for events like PlaybackStateChanged and others.

What is the difference between them?

1 answer

  • answered 2019-09-10 07:16 Martin Zikmund

    This duplication is actually caused by the fact that these "duplicated" MediaPlayer events are now deprecated. See the documentation for the BufferingStarted event for example:

    MediaPlayer.BufferingStarted may be altered or unavailable after Windows 10, version 1607. Instead, use the MediaPlayer.PlaybackSession property to get a MediaPlaybackSession object and then use the MediaPlaybackSession.BufferingStarted event.

    So you can safely use MediaPlayer.PlaybackSession instead and stay on the safe side with future updates.