【发布时间】:2014-04-16 05:55:50
【问题描述】:
我正在为音乐播放器创建应用程序,但在我的模拟器中没有音乐文件
所以我决定在MediaLibrary加几首歌
我写了以下代码来添加歌曲:
public void addsong()
{
try
{
Uri songUri = new Uri("../Assets/samplemusic/02 Can't Remember to Forget You (feat. Rihanna).mp3", UriKind.RelativeOrAbsolute);
//SaveFileToIsolatedStorage(songUri, "test.mp3");
MediaLibrary lib = new MediaLibrary();
SongMetadata metadata = new SongMetadata
{
GenreName = "Super Hit Songs",
Name = "Song 1",
AlbumName = "My Collections",
AlbumArtUri = new Uri("ApplicationIcon.png", UriKind.RelativeOrAbsolute)
};
MediaLibraryExtensions.SaveSong(lib, songUri, metadata, SaveSongOperation.CopyToLibrary);
}
catch (Exception ex)
{
}
}
但它不起作用,我不知道为什么
有人有想法吗?
【问题讨论】:
-
将音乐文件保存到独立存储而不是音乐库。
-
stackoverflow.com/questions/22979972/… 试试这个。如果您遇到任何问题,请告诉我们
标签: c# windows-phone-7 windows-phone-8 microsoft-metro windows-store-apps