Search code examples
windows-store-appswindows-phone-8.1mmppf

Why doesn't my audio play in the background?


I'm using this page to keep my audio playing across pages.

<Page
    x:Class="MyApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mmppf="using:Microsoft.PlayerFramework"
    mc:Ignorable="d"
    >

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <mmppf:MediaPlayer x:Name="player" AutoPlay="True" AudioCategory="BackgroundCapableMedia" />
        <Frame x:Name="rootFrame"/>
    </Grid>
</Page>

This is how my App Manifest looks. enter image description here

But once I background my app, the audio stops playing. From what I can see, everything mentioned here is present in my app

(the MediaPlayer element should take care of the SystemMediaTransportControls)


Solution

  • The page you're referring to is only applicable to Windows Store apps, not Windows Phone 8.1.

    For Windows Phone 8.1, things seem more complicated, as you have to implement a background task, as explained here: Overview: Background audio (Windows Phone Store apps)