Windows Phone 8 app. We're using AudioStreamingAgent/Mp3MediaStreamSource to play MP3 files which could be cached locally or loaded from web.
When file is downloaded we are still using AudioStreamingAgent /Mp3MediaStreamSource to ensure we will be able to precache next file while playing current. Yes, we could use just WP8 built-in player for cached files, but we will not be able to precache next file in this case.
Problem: After several tracks, BackgroundAudioPlayer doesn't start playing anymore.
After all, I see the track is shown in UVC, but it's in state "Paused". Pressing "Play" in UVC calls OnUserAction in background which calls player.Play(). Nothing changes.
Picture of "stuck state"
Sample with problem reproduction, VS 2012 (sample is based on Background Audio Streamer Sample)
Steps to reproduce with sample code:
The problem is reproduced both on device and on emulator, both on WP8 and WP8.1 developer preview.
Update: Running out of memory is not the case. Reproducing the problem using sample code and looking at the backgroundlog.xml file shows that sample uses only 6 Mb out of 20 Mb allowed Last column on this picture is "Memory usage|Max allowed memory usage"
In my experience with this, my suggestion would be to port and start working with WPA8.1 where the limitations with playing background audio go away.
In developing a music player app for WP and trying to cache music while using a mediastreamsource
, I finally came to the conclusion that it might not be possible. It seems that you have a set amount of time or some other variable before the OS stomps on any tasks or background type work being done.
I wrote this up for a MS evangelist: https://drive.google.com/file/d/0By_e5C-QWr9Ka3RmbVBlWVF3R1E/edit?usp=sharing
Here are some other SO's I favored when trying to solve this:
BackgroundAudioPlayer is 'Playing' but not calling GetSampleAsync()
WP7 background audio resources are no longer available
HttpWebRequest from AudioPlayerAgent
AudioPlayerAgent, timer and webservice
WP7 Mp3MediaStreamSource demo not working
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With