This project has moved and is read-only. For the latest updates, please go here.

Implementing Background Audio on WP8.1

Feb 16, 2015 at 6:42 PM
Hi, could I get a guide on how to implement Background Audio into WP 8.1 (non-SL) app? I tried copy pasting most of the code but I'm getting:
MainPage.NotifyBackground() 00bd0f3b-10fc-46dc-a046-c1dffa803a2b: ping
MainPage play
MainPage.RefreshUi(Closed, ) 00bd0f3b-10fc-46dc-a046-c1dffa803a2b
MainPage.NotifyBackground() 00bd0f3b-10fc-46dc-a046-c1dffa803a2b: ping
A first chance exception of type 'System.TimeoutException' occurred in App3.WindowsPhone.exe
A first chance exception of type 'System.TimeoutException' occurred in
MainPage playButton Click failed: Background task did not start
MainPage.RefreshUi(Closed, ) 00bd0f3b-10fc-46dc-a046-c1dffa803a2b
Thanks! >.<
Feb 16, 2015 at 7:45 PM
Do you have something like this in your Package.appxmanifest?
        <Extension Category="windows.backgroundTasks" EntryPoint="SM.Media.BackgroundAudio.SmMediaBackgroundAudioTask">
            <Task Type="audio" />
Feb 16, 2015 at 8:53 PM
Edited Feb 16, 2015 at 8:53 PM
Oops, that was it! Thanks!

Now how do I pass in a stream for it to play? Currently doing:
                        case MediaPlayerState.Paused:
                            mediaPlayer.SetUriSource(new Uri(""));
But that's not working.
Feb 24, 2015 at 3:15 PM
Oh, you're still working on it (judging from this and this). Sorry I can't be of any help, hope you get it working soon :)
Feb 24, 2015 at 5:40 PM
I have some local changes that are getting closer to actually working. It works with a list of tracks (like HlsView's TrackManager), but it is still not switching reliably between the tracks (Shoutcast stations or whatever).
Feb 24, 2015 at 7:19 PM
I've pushed some changes that get WP8.1's background audio working better. 0741be47883f adds support for multiple tracks and 7386ce926b9a gets things working more reliably. Occasionally, it will still get stuck changing tracks (at least with UseSingleStreamMediaManager enabled).
Feb 25, 2015 at 2:00 AM
Awesome! Thanks so much for this :)