2

我正在开发一个 Windows Phone 应用程序,它在后台播放/流式传输音乐。

为此,我尝试同时使用Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayerMicrosoft.Xna.Framework.Media.MediaPlayer类。在这两种情况下,一切都很好,所以我想知道这些方法的优点/缺点是什么,因为现在我无法决定哪个更好。

在 BackgroundAudioPlayer 中我唯一不喜欢的是,我需要为音频代理创建单独的项目,并且担心通过独立存储传输轨道信息。但既然我已经这样做了。这不是一个问题。

那么这两个类之间还有其他区别吗?

4

2 回答 2

2

It depends on your program. If you want to play your background music only while using your program, you should use MediaPlayer. Otherwise you have to take care of the BackgroundAudioPlayer in any situation. Also this will annoy users, who also want to listen to their own music while using your application.

Otherwise, if your background music is the main purpose of the program, the user would like to start your music and switch to other programs. Then it keeps playing and you can control the music in the volume bar. That's why you have to create a background task for BackgroundAudioPlayer. The main application will stop in both ways when switching to other programs.

In short: game background music should never play after leaving the game (use MediaPlayer) - but I never want to watch my music player counting the time, while listening to my music library (use BackgroundAudioPlayer).

于 2013-08-17T07:06:51.213 回答
1

我相信 MediaPlayer 要求应用程序处于前台。BackgroundAudioPlayer 将让用户开始播放曲目,退出您的应用程序,音乐将继续播放,并且代理可以响应 UVC。

确保在前台应用程序和后台音频代理之间进行通信时使用互斥锁。

于 2013-08-17T02:56:13.667 回答