none
Error: The background audio resources are no longer available.

    Question

  • I have diagnostics setup for my app and I get the following error more than any others:

    The background audio resources are no longer available.

    I have done some research and found other devs with this issue but they always seem to be using both the BackgroundAudioPlayer and MediaElements in the same app.  I do not use the MediaElement in my app only the BackgroundAudioPlayer. 

    I assume this is a similiar issue, maybe another app is using a MediaElement and when the user returns to my app and I attempt to Play or handle the state of the player in my app I get these errors.  I would gladly reset the player but I can't even read the state of the player without getting this error.


    Follow me on Twitter - @chief7

    Friday, August 17, 2012 11:19 AM

All replies

  • I assume this is a similiar issue, maybe another app is using a MediaElement and when the user returns to my app and I attempt to Play or handle the state of the player in my app I get these errors.  I would gladly reset the player but I can't even read the state of the player without getting this error.

    Are you using AudioPlayerAgent?

    There is a race condition where the AudioPlayerAgent receives a Pause action but the BackgroundAudioPlayer object is already owned by someone else, for example: if the user opens a youtube video link in the web browser.

    If your agent is already in the paused state you should still receive callbacks to OnPlayStateChanged with PlayState.Stopped and PlayState.Shutdown.

    AFAIK: As long as you handle any exception within the callback (and call NotifyComplete) you should be safe... but if you let an exception go unhandled then your Background Agent will be terminated.


    -Eric.

    Friday, August 17, 2012 10:59 PM
    Owner
  • Yes I'm using AudioPlayerAgent.

    I tried to reproduce the issue as you suggest by playing audio in my app and then going to the browser and playing a youtube video.  The video plays and I can still go back to my app and resume the music and it works without error.

    Should I wrap the entire contents of the OnPlayStateChanged method in a try/catch with the notify in the finally?

    I REALLY appreciate your help!


    Follow me on Twitter - @chief7

    Saturday, August 18, 2012 1:10 AM
  • Should I wrap the entire contents of the OnPlayStateChanged method in a try/catch with the notify in the finally?

    Yes, that would be a good defensive strategy.  The same caution should apply to other callback functions which need to call NotifyComplete, ex: OnUserAction, OnError, OnCancel.

    -Eric.

    Monday, August 20, 2012 1:48 PM
    Owner