How play a .mp3 (or other) file in a UWP app?

后端 未结 4 1136
眼角桃花
眼角桃花 2021-01-02 08:17

I try this:

PlayMusic = new MediaElement();
PlayMusic.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.Media;

PlayMusic.Source = new Uri(@\"C:\\Users\\Us         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 08:38

    You cannot just read any file on your file system like this with windows store applications.

    If you just want to test it:

    1. Add the file to your project in Visual Studio
    2. Change your file’s "Build Action" to "Content".
    3. Change "Copy to Output Directory" to "Copy Always".

    What you probably want to do is explained in the section, Read Local files w/o a Picker from this article. This might also be helpful.

提交回复
热议问题