Windows Phone 8. We use AudioStreamingAgent / Mp3MediaStreamSource to play MP3 files that can be cached locally or downloaded from the Internet.
When the file is uploaded, we still use the AudioStreamingAgent / Mp3MediaStreamSource to ensure that we can execute the next file during playback. Yes, we could only use the built-in WP8 player for cached files, but in this case we will not be able to execute the next file.
Problem: After several tracks, BackgroundAudioPlayer no longer starts playing.
- Running AudioStreamingAgent.OnBeginStreaming
- Code is executed to create a MediaStreamSource
- The AudioStreamer.SetSource method is executed with a new instance of MediaStreamSource
- PlayStateChanged is launched in the background using PlayState.TrackReady and player.Play () is called in this case.
In the end, I see that the track is shown in UVC, but it is in the "Paused" state. Clicking Play in UVC calls OnUserAction in the background, which calls player.Play (). Nothing changes.
Image of "stuck state"
An example of reproducing a problem, VS 2012 (sample based on Background Example audio stream )
Steps to reproduce with sample code:
- Install the application
- Click the "Preload tracks" button. It copies mp3 files from XAP to IsolStorage.
- Click the "Track 1" button. After the track starts playing, press the "Track 2" button. Then, after starting playback of track 2, press the "Track 3" button.
- Continue to step 3 until after the โTrack *โ button is pressed, the track starts playing.
- The last selected track will be displayed as the active track both in UVC and higher on the progress bar on the page (see picture )
- Pressing other track buttons in most cases does not matter.
The problem is reproduced both on the device and on the emulator, both on the preview of WP8 developers, and on WP8.1.
Update. Running from memory is wrong. Reproducing the problem using the sample code and viewing the backgroundlog.xml file shows that the sample uses only 6 MB of the 20 MB allowed . The last column in this image is โMemory Usage | Maximum Allowable Memory Usageโ
source share