如何在Windows 8中在线播放背景音乐 [英] How to play background music online in Windows 8
本文介绍了如何在Windows 8中在线播放背景音乐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,我使用UI MediaElement.但是,当我单击Windows键时,音乐就会停止.
我尝试使用:
MediaControl.PlayPressed + = MediaControl_PlayPressed;MediaControl.PausePressed + = MediaControl_PausePressed;MediaControl.PlayPauseTogglePressed + = MediaControl_PlayPauseTogglePressed;MediaControl.StopPressed + = MediaControl_StopPressed;
我设置了源MediaElement:
media.Source =新的Uri("http://stream-hq.mp3.zdn.vn/fsgggsfdlwjglwjAAAAA/2a3f830202ea6d29bc7c5a5146401566/4ff5620a/2011/12/27/a/4/a4fcc199a184a93cfeb0fe353c53,".RelativeOrAbsolute);
请帮助我!
解决方案
要使Metro/WinRT应用在后台播放音频,该应用需要以下条件:
- 捕获硬件按钮(例如,键盘上的播放/暂停)和
Please help me!
解决方案For a Metro/WinRT app to play audio in background, the app needs the following:
- A MediaElement control that:
- Is in a XAML page.
- The AudioCategory property set to BackgroundCapableMedia (as in Armando's answer). There are other values for games or communication systems as needed. See the Audio Playback in a Metro Application for information on what the different options mean.
- Use the MediaControl object to capture at least the following. Other events and properties can be handled if desired but the following are required for background playback to function.
- Add audio to the list of support background tasks in the applications manifest. The manifest is usually called
Package.appxmanifest
. Select it in the Solution Explorer, go to the Declarations tab and check "Audio" as shown:
See the Transport Controls Guide for more info about capturing hardware buttons (e.g. play/pause on the keyboard) and the quickstart guide for creating a media player for more info.
这篇关于如何在Windows 8中在线播放背景音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- A MediaElement control that:
查看全文