Reputation: 48185
I'm using BackgroundAudioPlayer
agent in my Windows Phone 7 application. When the track end, the agent side receives TrackEnded
event, but UI side doesnot receive any events.
Also, when I intentionally set audio track 's position to its end, then call Play()
, the agent side receives TrackEnded
event (because the track has come to an end), but the UI side does receive Stopped
in its PlayStateChanged
handler. So weird !
How to let UI know that an track has come to an end ? Communicating through isolated storage is not my favorite !
Upvotes: 2
Views: 274
Reputation: 2727
From research and a little testing, using Isolated Storage as a middle-man between Background and Foreground instances of the BackgroundAudioPlayer
is still the only route for Windows Phone 7. The options are mentioned here (which I know you're aware of)...
http://blogs.msdn.com/b/wpukcoe/archive/2012/02/10/background-audio-in-windows-phone-7-5-part-2.aspx
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202944(v=vs.105).aspx
https://stackoverflow.com/a/11419680/247257
This was also confirmed by Peter Torr who said:
For example, the agent may need to tell the foreground “I just started pre-downloading the next track,” or “I updated a database table and you should refresh your state”. Such notifications are impossible to create with Windows Phone OS 7.1; at best you can model them by using polling techniques, but this approach is inefficient and prone to errors.
The only good news is that in the same post, he gives a solution (using named events for IPC) for Windows Phone 8 which is a lot more reliable...
Upvotes: 1