I have a UWP Desktop application for playing audios. I'm using a MediaPlayerElement and setting the MediaPlayer's Source property to a MediaPlaybackList. I have two questions:
How to know when the user presses one of the MediaPlayerElement buttons (play, pause, next track, etc.)?
How to change the running track programmatically?
<MediaPlayerElement x:Name="mediaPlayerElement" AutoPlay="False" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,0,100" AreTransportControlsEnabled="True" > <MediaPlayerElement.TransportControls> <MediaTransportControls IsSkipBackwardEnabled="False" IsSkipBackwardButtonVisible="False" IsSkipForwardEnabled="False" IsSkipForwardButtonVisible="False" IsFastForwardButtonVisible="True" IsFastForwardEnabled="True" IsFastRewindButtonVisible="True" IsFastRewindEnabled="True" IsFullWindowButtonVisible="False" IsNextTrackButtonVisible="True" IsPreviousTrackButtonVisible="True" IsZoomButtonVisible="False"/> </MediaPlayerElement.TransportControls> </MediaPlayerElement> MediaPlaybackList mediaPlaybackList = new MediaPlaybackList(); public PlayerPage() { this.InitializeComponent(); CreatePlaylist(); mediaPlayerElement.MediaPlayer.Source = mediaPlaybackList; }
Please refer to the case reply here. And listen
SystemMediaTransportControlsButtonPressedevent, then you could get Next or Previous pressed.What's the running track, do you means playing order? MediaPlaybackList has ShuffleEnabled property. You could set it as true to playing shuffle.