private void OnSeekTo(SystemMediaTransportControls sender, PlaybackPositionChangeRequestedEventArgs args) { JObject obj = new JObject(); obj.Add("position", args.RequestedPlaybackPosition.TotalSeconds); manager.SendEvent(Events.ButtonSeekTo, obj); }
private void systemMediaControls_PlaybackPositionChangeRequested(SystemMediaTransportControls smtc, PlaybackPositionChangeRequestedEventArgs args) { mbApiInterface.Player_SetPosition(args.RequestedPlaybackPosition.Milliseconds); }
private void _SMTC_PlaybackPositionChangeRequested(SystemMediaTransportControls sender, PlaybackPositionChangeRequestedEventArgs args) { WriteChromeNativeMessageToSTDIO(new JProperty("Command", new JProperty("RequestedPlaybackPosition", args.RequestedPlaybackPosition))); }
/// <summary> /// Handles a request from the System Media Transport Controls to change our current playback position. /// </summary> private async void systemMediaControls_PlaybackPositionChangeRequested(SystemMediaTransportControls sender, PlaybackPositionChangeRequestedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // First we validate that the requested position falls within the range of the current piece of content we are playing, // this should usually be the case but the content may have changed whilst the request was coming in. if (args.RequestedPlaybackPosition.Duration() <= mediaPlayer.PlaybackSession.NaturalDuration.Duration() && args.RequestedPlaybackPosition.Duration().TotalSeconds >= 0) { // Next we verify that our player is in a state that we think is valid to change the position if (mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Paused || mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing) { // Finally if the above conditions are met we update the position and report the new position back to SMTC. mediaPlayer.PlaybackSession.Position = args.RequestedPlaybackPosition.Duration(); UpdateSmtcPosition(); } } rootPage.NotifyUser("Playback position change requested", NotifyType.StatusMessage); }); }
/// <summary> /// Handles a request from the System Media Transport Controls to change our current playback position. /// </summary> private async void systemMediaControls_PlaybackPositionChangeRequested(SystemMediaTransportControls sender, PlaybackPositionChangeRequestedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // First we validate that the requested position falls within the range of the current piece of content we are playing, // this should usually be the case but the content may have changed whilst the request was coming in. if (args.RequestedPlaybackPosition.Duration() <= mediaPlayer.PlaybackSession.NaturalDuration.Duration() && args.RequestedPlaybackPosition.Duration().TotalSeconds >= 0) { // Next we verify that our player is in a state that we think is valid to change the position if (mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Paused || mediaPlayer.PlaybackSession.PlaybackState == MediaPlaybackState.Playing) { // Finally if the above conditions are met we update the position and report the new position back to SMTC. mediaPlayer.PlaybackSession.Position = args.RequestedPlaybackPosition.Duration(); UpdateSmtcPosition(); } } rootPage.NotifyUser("Playback position change requested", NotifyType.StatusMessage); }); }