WP7 Mango:如何处理从音频播放代理类库之外的 UVC 跳过下一个/上一个? [英] WP7 Mango: How to handle skip next/previous from UVC outside of the Audio Playback Agent class library?

查看:15
本文介绍了WP7 Mango:如何处理从音频播放代理类库之外的 UVC 跳过下一个/上一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 Windows Phone 音频播放代理的信息似乎有点稀缺,我能找到的唯一真实的文章来自 MSDN.

Information on the Windows Phone Audio Playback Agent seems to be somewhat scarce, and the only real article I can find is the one from MSDN.

不幸的是,示例中的实现对于大多数应用来说并不实用,因为它们使用音频播放代理类库中包含的 AudioTrack 的静态列表.对于大多数应用程序,我想它们会在应用程序的主项目(即视图模型或类似的东西)中管理一个动态的 AudioTracks 列表.但是,这里的问题是音频播放代理似乎没有一种有效的方式与应用程序的其余部分进行通信.我知道我可以注册 BackgroundAudioPlayer.Instance.PlayStateChanged 事件,但没有 SkipPrevious 或 SkipNext 事件.

Unfortunately, the implementation in the sample is not practical for most apps, as they use a static list of AudioTracks contained within the Audio Playback Agent class library. For most apps, I'd imagine they would have a dynamic list of AudioTracks managed within the application's main project (ie. View Model or something similar). The issue here though, is that there doesn't seem to be an effective way for the Audio Playback Agent to communicate with the rest of the application. I know I can register for the BackgroundAudioPlayer.Instance.PlayStateChanged event, but there is no event for SkipPrevious or SkipNext.

简单地问——如果您在音频播放代理项目之外管理您的音轨,当用户使用通用音量控制 (UVC) 上的 SkipPrevious/SkipNext 按钮时,您将如何处理?

Asked simply -- if you manage your AudioTracks outside of the Audio Playback Agent project, how can you handle when a user uses the SkipPrevious/SkipNext buttons on the Universal Volume Control (UVC)?

推荐答案

您需要将围绕播放曲目的逻辑移动到代理(或代理可以使用的库)中.这是必要的,因为即使应用未运行,代理也必须能够运行.

You need to move the logic around what tracks to play into the agent (or a library the agent can use). This is necessary as the agent must be abel to run even when the app isn't running.

从您的应用跟踪代理中发生的事情的唯一方法是订阅 BackgroundAudioPlayer.Instance.PlayStateChanged 事件.这将在使用通用控件时触发.

The only way to track what is happening in the agent from you app is to subscribe to the BackgroundAudioPlayer.Instance.PlayStateChanged event. This will be fired when the universal controls are used.

正如您所指出的,这极大地限制了您可以在应用中包含的信息数量(例如,与 MediaElement 相比).

As you've noted this greatly limits the amount if information you can include in the app (compared with MediaElement, for instance).

重要请注意,您移动到代理(或代理引用的库)中的任何逻辑都不会使用任何受限 API,即使它们位于代理引用的程序集中且未使用静态分析市场认证完成的代理将导致其失败.

Important Be careful that any logic you move into the agent (or a library referenced by the agent) does not use any of the restricted APIs as even if they're in an assembly referenced by the agent and not used the static analysis of the agent done by marketplace certification will cause it to fail.

这篇关于WP7 Mango:如何处理从音频播放代理类库之外的 UVC 跳过下一个/上一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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