locked
SystemMediaTransportControls Not Working RRS feed

  • Question

  • I'm having issues with the new SystemMediaTransportControls that replace MediaControl.

    Currently, I have my app set up with:-

                systemControls = SystemMediaTransportControls.GetForCurrentView();
                systemControls.IsPlayEnabled = true;
                systemControls.IsStopEnabled = true;
                systemControls.IsPauseEnabled = true;
                systemControls.ButtonPressed += SystemControls_ButtonPressed;


    And

    async void SystemControls_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args) { System.Diagnostics.Debug.WriteLine(args.Button); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { switch (args.Button) { case SystemMediaTransportControlsButton.Play: if (mediaElement1.CurrentState != MediaElementState.Playing) { restartSource(); } else { completeClosure(); } break; case SystemMediaTransportControlsButton.Pause:

                        case SystemMediaTransportControlsButton.S t o p :
                            completeClosure();
                            break; default: break; } }); }

    And

            private async void completeClosure()
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    mediaElement1.Stop();
                    mediaElement1.Source = null;
                    timer.Stop();
                });
            }
    
            private async void restartSource()
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    mediaElement1.Source = new Uri(holdThisSource, UriKind.Absolute);
                    mediaElement1.Play();
                    timer.Start();
                });
            }


    When a user presses the Pause Button, args.Button shows up as "Play", hence the need for the checking for MediaElement's state. However, when I attempt to resume to media, it successfully resumes in restartSource() and updates the app accordingly but the icon on the Volume Control does not change from the Play sign, although hardware buttons still work.

    Along with this, pressing the hardware Stop button NEVER works, and fails to even show up in Debug.WriteLine.

    This is an online streaming app where the source does not allow resuming and thus I have to close the stream this way.

    I'd love some help on this.

    Thursday, October 24, 2013 5:07 PM

Answers

All replies