如何在UWP应用中播放.mp3(或其他)文件? [英] How play a .mp3 (or other) file in a UWP app?
本文介绍了如何在UWP应用中播放.mp3(或其他)文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试:
PlayMusic = new MediaElement();
PlayMusic.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.Media;
PlayMusic.Source = new Uri(@"C:\Users\UserName\Desktop\C:\Users\user\Desktop\Kill The Alarm - Begin Again.mp3");
PlayMusic.Play();
显示器上不再显示任何错误消息(尝试捕获完全清除).
No more error messages appear on the display (try catch runs clean through).
对不起,简短说明... 我能很好地阅读和理解英语,但是我很难说和写.
Sorry for the short description... I can read and understand English very well but it is difficult for me to talk and write.
推荐答案
每个Windows Store App都有三个文件夹.一个本地文件夹,一个漫游文件夹和一个临时文件夹.每个都以相同的方式访问.本地用于将资产存储在特定于应用程序的本地文件夹中.
Every Windows Store App has three folders. A Local folder, a Roaming folder and a Temp folder. Each is accessed the same way. Local is meant to store assets in a local, application-specific folder.
这是答案:
StorageFolder Folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
Folder = await Folder.GetFolderAsync("MyFolder");
StorageFile sf = await Folder.GetFileAsync("MyFile.mp3");
PlayMusic.SetSource(await sf.OpenAsync(FileAccessMode.Read), sf.ContentType);
PlayMusic.Play();
MfG.
这篇关于如何在UWP应用中播放.mp3(或其他)文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文