locked
WP 8.1 Audio background task stops

    Question

  • Hi,

    We are developing a sport app in which we give audio alerts of Live Score periodically, say at every 5 mins and alerts of key events as well. Right now we are able to do it while keeping app in foreground i.e. running state. But our requirement is to keep giving live score audio alerts to user even if app is in suspended state (if user has opted so via settings of app). We are trying to implement this via background audio task. Once app goes in suspended state we send a message to background task and then background task starts polling web service at every 1 min to get the score and any key event. If we get some event for audio alert we play that using

    BackgroundMediaPlayer.Current.Play()

    Sometimes it works fine for the whole game other times background task stops. In Cancelled event I get reason 'SystemPolicy'. I am logging memory in Canceled event and I can say its not happening due to memory constraint. I suspect somehow I am violating CPU time or some other constraint.

    As I know in WP8.1 there is two type of constraint (apart from low battery) for background task

    1. CPU time limit of 2 seconds

    2. Memory constraint which depends on device RAM

    Am I missing some constraint here? Memory, I am not violating. CPU time I am not sure as I don't know how can I track CPU usages time.

    Where should I be looking to fix the problem? What can be possible reasons for which OS may be killing background audio task?

    Is there any better way to implement this functionality? I thought of using push rather than polling but can't communicate push background task with audio background task.

    Thanks,

    Chandan

    Friday, March 27, 2015 9:41 AM

Answers

  • Hi Chandan,

    Sometimes it works fine for the whole game other times background task stops.

    -> Is that means the background task actually works but unstable, I believe the issue related with the limitation of the background task as you mentioned, see this for more information: Supporting your app with background tasks.

    Where should I be looking to fix the problem? What can be possible reasons for which OS may be killing background audio task?

    -> Your app is kind of sending background request every 1 mins, and if there is audio returned, play that audio, but how about your background request does not send successfully? I don't think its something like killing the background task but instead its something background task is limited.

    Is there any better way to implement this functionality?

    -> How about setting the alert or reminder? Not sure what is your audio scenario, but seems there is no good suggestion at this time, probably working with Windows Phone 8 can help Running location-tracking apps in the background for Windows Phone 8, or just raise the feedback to our product group: https://wpdev.uservoice.com/forums/110705-dev-platform

    Thanks for your understanding,

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Chandan Mourya Wednesday, April 01, 2015 1:28 PM
    Monday, March 30, 2015 8:17 AM
    Moderator