简体   繁体   English

将音乐添加到Windows 8.1应用-Visual Studio 2013

[英]Add music to windows 8.1 app - Visual studio 2013

I'm creating a windows app , windows 8.1 app, using visual studio 2013. 我正在使用Visual Studio 2013创建Windows应用程序Windows 8.1应用程序。

i want to add a background music to it. 我想为其添加背景音乐。

how to add it? 怎么添加呢?

Do you mean music while the app is playing or music running when the app is in the background? 您是指在应用程序播放时播放音乐还是在后台运行音乐?

For both you'll set up a MediaElement running the music file you want to play. 两者都将设置一个MediaElement来运行您要播放的音乐文件。

Since the MediaElement will only play while it's in the visual tree you need to play a small trick to keep it running through all of the app's pages: instead of running the app out of a top-level page, create a root page with the MediaElement and a child frame, then run the app's pages out of the child frame. 由于MediaElement仅在它在视觉树中时才播放,因此您需要玩一个小技巧以使其在应用程序的所有页面中运行:不要在顶层页面之外运行该应用程序,而应使用MediaElement创建一个根页面和子框架,然后在子框架之外运行应用程序的页面。 See my blog entry Frame of reference: keeping the music playing across pages for more details. 请参阅我的博客条目“参考框架:保持音乐跨页面播放”以了解更多详细信息。

To play music when the app is in the background you'll need to declare the background audio task, set the MediaElement to BackgroundCapableMedia, and wire up SystemMediaTransportControls. 要在应用程序处于后台时播放音乐,您需要声明后台音频任务,将MediaElement设置为BackgroundCapableMedia,然后连接SystemMediaTransportControls。 See the How to play audio in the background documentation on MSDN for details. 有关详细信息,请参见MSDN上的后台文档中的如何播放音频”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows 8.1上安装SDL并将其连接到Visual Studio Community 2013 - How to install SDL on Windows 8.1 and to connect it to Visual Studio Community 2013 Visual Studio 2013-Windows 7创建应用程序包 - Visual Studio 2013 - Windows 7 create app package Visual Studio 2013和Windows 8.1 .. Windows Phone Emulator无法启动,HYper V问题 - Visual studio 2013 and Windows 8.1 .. Windows Phone Emulator wont launch,, HYper V issue 如何将Visual Studio 2013配置为链接到Windows Kit 10而不是8.1 - How to I configure Visual Studio 2013 to Link to Windows Kit 10 and not 8.1 使用Visual Studio 2013构建Windows Phone 8应用 - Build windows phone 8 app using visual studio 2013 停止Windows 8.1中的Xbox音乐应用程序下载音乐专辑专辑 - Stop Xbox Music app in Windows 8.1 from downloading Album Art for Music 新项目上的Windows 7 Visual Studio“需要Windows 8.1” - Windows 7 Visual Studio “windows 8.1 required” on new project Visual Studio 2008中的PostBuild在Windows 7或Windows 8.1下无法正常工作 - PostBuild in Visual Studio 2008 not working under Windows 7 or Windows 8.1 无法在Visual Studio 2013中为Cordova Windows Phone应用程序在“设备”上运行选项 - Not getting option of run on “Device” for a cordova windows phone app in visual studio 2013 将椭圆添加到图像并将其保存在Windows 8.1 APP中 - Add ellipse to the image and save it in Windows 8.1 APP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM