none
My Windows Store app stops playing audio when minimized

    Question

  • Hi guys,

    I have a PWA / hosted web app that is published in the Windows Store here. It's an music app, and it works fine...unless I minimize the app.

    When I minimize the app, the audio stops playing. How can I fix this?

    My first thought was, "Oh, I need to specify the backgroundMediaPlayback capability in my appxmanifest.xml"


    I did that (view my appxmanifest.xml here), but it still doesn't play audio while minimized. My appxmanifest has the following:

    <Capabilities>   
       <Capability Name="internetClient" />   
       <uap3:Capability Name="backgroundMediaPlayback" />
    </Capabilities>

    But this still doesn't work.

    What do I need to do to make my Windows Store app be able to play audio even while minimized?


    Judah Gabriel Himango

    Thursday, March 8, 2018 7:43 PM

All replies

  • Hi Judah Gabriel Himango,

    In general, if you have enabled backgroundMediaPlayback capability, you will be able to play audio or video in background.

    I made a simple test like this:

      public MainPage()
            {
                this.InitializeComponent();
                MediaPlayer mediaPlayer = new MediaPlayer();
                mediaPlayer.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/123444.mp3"));
                mediaPlayer.Play();
    
            }

    And I enabled the capability. When I minimize the app, it is still playing.

    Could you please tell me your OS version and target version?

    How you play the audio, using mediaplayer or MediaPlayerElement?

    Best regards

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, March 9, 2018 4:01 AM
    Moderator
  • Hi Roy,

    My app is an HTML5 progressive web app. I packaged it for the Windows Store using Microsoft's pwabuilder.com

    Audio: I'm a hosted web app, so my audio is using the HTML5 <audio> tag.

    OS: I'm on Windows 10 Pro, version 1709 build 16299.248. If you want to test it on other versions, you can grab the free app from the Windows Store. To repro, just click play, then minimize.

    Target version: Windows 10.0.10240.0


    Judah Gabriel Himango



    Friday, March 9, 2018 4:00 PM
  • @Judah Gabriel Himango,

    From the official sample for Background Media playback, you might need to use MediaPlayer in the JS code instead of using Audio tag.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 12, 2018 9:35 AM
    Moderator
  • Hi Roy,

    I tried to reply to this a few days ago and the forum software kept giving me a 500 error.

    Looking at the Background Media Playback article you linked to, it appears HTML5 audio should work:

    Adding the [background media playback] capability enables the following:

    • All media playback APIs become background enabled. That means you can use any platform audio APIs, such as MediaPlayer, AudioGraph, XAudio2, and the HTML Audio tag.

    If I'm reading that right, HTML5 audio should work with the background media playback.



    Judah Gabriel Himango

    Wednesday, March 14, 2018 2:37 PM
  • For what it's worth, I posted this question over on StackOverflow, and pinged the Windows Developer support team on Twitter.

    They suggested the issue is that my app manifest was targetting the earliest version of Windows 10, which didn't support backgroundMediaPlayback capability.

    So, in my app manifest, I changed the target Windows 10 versions to the following:

    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.14393.0" MaxVersionTested="10.0.16299.0"/> 

    I'm publishing this update to the Store now to see if this fixes the problem. I'll update the post here when I find out.


    Judah Gabriel Himango

    Wednesday, March 14, 2018 3:56 PM
  • @Judah Gabriel Himango,

    Sorry for missing the message.

    If you still have problem after changing the target version, feel free to contact us.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 15, 2018 9:44 AM
    Moderator