1

I'm using BackgroundAudioPlayer for my Windows Phone 7 music & video application. After I play some music, I play video using MediaPlayerLauncher, then press Back to return to my app. There whenever I use BackgroundAudioPlayer.Instance. I receive error "The background audio resources are no longer available".

Someone on MSDN suggests using try/catch, but this is not a good idea, and can slow down the app.

Other suggests call BackgroundAudioPlayer.Instance.Close() before launch MediaPlayer. However, when I play music, the agent load .dll again, which takes very much time.

How to fix this ?

4

1 回答 1

2

如果您在音频之后播放视频,操作系统肯定会“终止”您的背景音频播放器。从您的问题来看,这似乎是 100% 可重现的,这将证实这一点。您唯一的选择是在您致电后再次重新启动后台音频播放器BackgroundAudioPlayer.Instance.Close(),然后播放您的视频。正如您所说,当您启动 BAP 时,需要重新加载您的播放器 DLL。

更新评论跟进

如果您没有实现流式音频代理,而只是实现了 AudioPlayer 代理,那么无论如何您都不会杀死进程。操作系统会在需要让您处理某个操作(例如:用户操作、跟踪结束、关闭)时启动一个进程。

BackgroundAudioPlayer.Instance.Close()只需确保操作系统在诸如 OP 之类的场景中干净地释放这些资源。

要重新启动背景音频,只需BackgroundAudioPlayer.Instance.Play()再次调用即可。

于 2012-11-30T18:27:55.367 回答