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 = new Uri("http://stream-hq.mp3.zdn.vn/fsgggsfdlwjglwjAAAAA/2a3f830202ea6d29bc7c5a5146401566/4ff5620a/2011/12/27/a/4/a4fcc199a184a93cfeb0fe35642.相对或绝对);请帮帮我!
要让 Metro/WinRT 应用在后台播放音频,应用需要满足以下条件:
- 一个 了解更多信息捕获硬件按钮(例如键盘上的播放/暂停)和 创建媒体播放器的快速入门指南了解更多信息.
In my application, I use UI MediaElement. But when i click the Windows key, the music stops.
I tried using:
MediaControl.PlayPressed += MediaControl_PlayPressed; MediaControl.PausePressed += MediaControl_PausePressed; MediaControl.PlayPauseTogglePressed += MediaControl_PlayPauseTogglePressed; MediaControl.StopPressed += MediaControl_StopPressed;I set source MediaElement:
media.Source = new Uri("http://stream-hq.mp3.zdn.vn/fsgggsfdlwjglwjAAAAA/2a3f830202ea6d29bc7c5a5146401566/4ff5620a/2011/12/27/a/4/a4fcc199a184a93cfeb0fe35642c53bf.mp3", UriKind.RelativeOrAbsolute);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.
- PlayPressed
- StopPressed
- PlayPauseTogglePressed
- PausePressed
- 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 中在线播放背景音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
- A MediaElement control that:
本文标题为:如何在 Windows 8 中在线播放背景音乐
- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
