locked
how to play media player in background again?

    Question

  • To play media player in background again. Media
    player in background is working but after setting changed if we stop the media.it is not playing in background agagin
    Wednesday, April 23, 2014 1:13 PM

All replies

  • Audio in background is play .I want user set the audio in background is play or not. if they select no then audio in background is stop but again if we set audio in background is play then background audio is not play again.
    Thursday, April 24, 2014 6:15 AM
  • I'm not sure what you're doing or where this is going wrong. Can you provide a minimal sample and clear repro steps to demonstrate the problem?

    --Rob

    Monday, April 28, 2014 11:50 PM
    Owner
  • 1.First we set background audio when page load. Audio in background is play.

    systemControls =

    SystemMediaTransportControls.GetForCurrentView();

                systemControls.ButtonPressed += MediaControl_PlayPressed;

                systemControls.ButtonPressed += MediaControl_PausePressed;          

                systemControls.IsPlayEnabled =

    true;

                systemControls.IsPauseEnabled =

    true;

                mediaplayer.Source =

    newUri("ms-appx:///Assets/Audio/Weight Loss, general track.mp3");

                VideoPlayer.Source =

    newUri("ms-appx:///Assets/Video/water background loop (iPhone Retina).mov");

                VideoPlayer.MediaEnded += VideoPlayer_VideoEnded;

                VideoPlayer.AutoPlay=

    true;

                mediaplayer.AutoPlay=

    true;

                mediaplayer.MediaEnded += mediaplayer_AudioEnded;

    2.Event

       

    privateasyncvoidMediaControl_PausePressed(SystemMediaTransportControlssender, SystemMediaTransportControlsButtonPressedEventArgse)

            {

               

    //sender = sender ?? new object();


               

    //e = e ?? new object();


               

    awaitDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => mediaplayer.Stop());

            }

           

    privateasyncvoidMediaControl_PlayPressed(SystemMediaTransportControlssender, SystemMediaTransportControlsButtonPressedEventArgse)

            {

               

    awaitDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => mediaplayer.Play());

            }

    3.we set audio play in background is no

      systemControls.IsEnabled =

    false;

               systemControls.IsPlayEnabled =

    false;

                systemControls.IsPauseEnabled =

    false;

    4.wgen we again set audio play in background is yes then audio in background is yes.

    systemControls.IsEnabled =

    true;

                systemControls.IsPlayEnabled =

    true;

    systemControls.IsPauseEnabled =

    true;

    Monday, May 5, 2014 7:01 AM