的Windows Phone 8 - 2背景音像冲突与这两个应用程序的终止 [英] Windows Phone 8 - 2 Background Audios Clash and both of the App terminates

查看:172
本文介绍了的Windows Phone 8 - 2背景音像冲突与这两个应用程序的终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

围绕一个星期前,我提交了一个在线的背景广播流媒体应用程序为Windows Phone商店。该应用程序是相当不错的(为我所用模拟器来测试它,这是很好的在所有可能的领域),但是当我提交进行认证,它失败了。

around a week ago, I submitted an online Background Radio Streaming app for the Windows Phone store. The app was quite good (as I used the Emulator to test it, it was good on all the possible sectors) but when I submitted it for certification, it failed.

根据错误日志,如果有人已在播放从音乐+视频集线器的音乐,然后尝试打开这个应用程序,无论是应用程序崩溃和意外停止的。

According the the error log, if someone is already playing a Music from Music + Video hub and then tries to open this app, both of the apps Crash and stop unexpectedly.

到目前为止,我的理解,这是因为音乐+视频中心的音乐也是背景音乐,并在同一时间玩2背景音乐,应用程式的崩溃。它可以是一些其他的原因,但所描述的人似乎更合乎逻辑的我。

So far I understood, it is because the Music of Music + Video hub is also Background Music and for playing 2 Background Musics at the same time, the apps are Crashing. It can be some other reason but the described one seemed more logical to me.

那么,有没有人谁可以告诉我如何改变音乐的应用程序的状态+视频集线器?我想暂停或停止音乐+视频中心的应用程序暂且这样既应用的状态是不一样的。这样一来,该应用程序将不会与背景相互冲突。

So, is there anyone who can tell me how to change the state of the app of Music + Video hub? I want to pause or stop the app of Music + Video hub for the time being so that both of the states of the app are not same. In that way, the apps won't clash with each other in the background.

谁能帮助我在这方面?

推荐答案

使用gameHasControl检查其它BAP用音乐:

Use gameHasControl to check for other BAP using music:

bool gameHasControl = Microsoft.Xna.Framework.Media.MediaPlayer.GameHasControl;
if (!gameHasControl)
{
   MessageBox.Show("stopping other player"); // normally you should ask if to do that      
   BackgroundAudioPlayer.Instance.Stop();
}



一旦停止,当你开始你的BAP,那么旧实例调用关机(),和你的BAP将成为新的实例,您可以正常使用了。同样是当你的BAP是在内存中,你开始从音乐+视频中心

$ B $玩只有B看出来,因为当你使用XNA,你有时需要做的:

Once it is Stopped, when you start your BAP, then old instance invokes Shutdown(), and your BAP will be new Instance, which you can normally use. The same is when your BAP is in memory and you start to play from Music+Video Hub.

Only watch out, because when you use XNA, you sometimes need to do:

FrameworkDispatcher.Update();



否则,您的应用程序有时会崩溃。祝你好运


修改 - 后评论


。要使它工作,你需要添加到Microsoft.P​​hone.BackgroundAudio参考或使用这样的:

Otherwise your App will sometimes crash. Good luck.

EDIT - after comment

To make it work you need to add a reference to Microsoft.Phone.BackgroundAudio or use like this:

Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer.Instance.Stop();



BackgroundAudioPlayer是辛格尔顿你被允许使用 - 在这种情况下 - 停止玩它(当然得选择到用户)

BackgroundAudioPlayer is a Singleton which you are allowed to use - in this case - Stop it playing (of course give the choice to the User).

这篇关于的Windows Phone 8 - 2背景音像冲突与这两个应用程序的终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆