Preinitialize BackgroundAudioPlayer in WP7?

2019-04-09 16:54发布

When I am using the BackgroundAudioPlayer in my Windows Phone 7 application, it takes a lot of time to load the first time I want to play a song. Is there any way of preinitializing the BackgroundAudioPlayer before playing the first track, so that when I start playing, it starts right along? I have googled it, but no luck. I am just using BackgroundAudioPlayer.Instance when I e.g. want to play, pause, stop etc an audiotrack. Is there something other i could do to fix this?

2条回答
Anthone
2楼-- · 2019-04-09 17:43

This might be looking at this from a simple angle, but could you not call play and then instantly pause it until you are ready to play?? I'm not hugely familiar with the control but looking here:

http://msdn.microsoft.com/en-us/library/microsoft.phone.backgroundaudio.backgroundaudioplayer_members(v=vs.92).aspx

Upfront you could possibly check BufferingProgress and PlayerState to check when the track is ready to play, and then pause until you're ready to continue.

It's a bit brute force but may work. Worth a try?

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-04-09 17:44

You could just call BackgroundAudioPlayer.Instance.Stop(); in your App constructor and then discard the first occurance of UserAction.Stop in the OnUserAction method in your implementation of AudioPlayerAgent

查看更多
登录 后发表回答