BackgroundAudioPlayer does not start playing

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โ€

+6
source share
1 answer

In my experience, my suggestion would be to port and start working with WPA8.1, where the limitations with playing back background sound go away.

When developing a music player application for WP and trying to cache music using mediastreamsource I finally came to the conclusion that this might not be possible. It seems that you have a certain amount of time or some other variable before the OS starts stomping when performing any tasks or background type.

I wrote this for MS Preacher: https://drive.google.com/file/d/0By_e5C-QWr9Ka3RmbVBlWVF3R1E/edit?usp=sharing

Here are some others that I prefer when trying to solve this problem:

BackgroundAudioPlayer is a "Playback" but not a call to GetSampleAsync ()

WP7 background audio resources are no longer available

HttpWebRequest by AudioPlayerAgent

AudioPlayerAgent, timer and web service

WP7 Mp3MediaStreamSource not working

+1
source

Source: https://habr.com/ru/post/971200/


All Articles