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.
- AudioStreamingAgent.OnBeginStreaming is executed
- Сode to create MediaStreamSource is executed
- AudioStreamer.SetSource method is executed with new MediaStreamSource instance
- PlayStateChanged is fired in background process with PlayState.TrackReady and player.Play() is called in this case.
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.
Sample with problem reproduction, VS 2012 (sample is based on Background Audio Streamer Sample)
Steps to reproduce with sample code:
- Install app
- Press button "Preload tracks". It copies mp3 files from XAP to IsolatedStorage.
- Press "Track 1" button. After track starts playing, press button "Track 2". Then, after track 2 starts playing, press button "Track 3".
- Keep doing step 3 until after pressing "Track *" button track doesn't start playing.
- Last track selected will be shown as an active track both in UVC and above progress bar on the page (see picture)
- Pressing other track buttons in most cases doesn't make any difference.
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"
MediaStreamSource
was an absolute requirement. – Billi