我基本上下载了一个文件名custom.mp3到我的isolationstorage中,我可以通过isolationstorage explorer来查看它....如何通过URI(WP7)访问IsolatedStorage中下载的声音?
这里的问题是...如何通过URI访问特定的custom.mp3?
到目前为止,我得到了这个..但我不知道为什么它不工作:
alarm.Sound = new Uri("isostore:/custom.mp3", UriKind.Absolute);
我基本上下载了一个文件名custom.mp3到我的isolationstorage中,我可以通过isolationstorage explorer来查看它....如何通过URI(WP7)访问IsolatedStorage中下载的声音?
这里的问题是...如何通过URI访问特定的custom.mp3?
到目前为止,我得到了这个..但我不知道为什么它不工作:
alarm.Sound = new Uri("isostore:/custom.mp3", UriKind.Absolute);
你的道路是错误的。你的代码没有其他错误。如果您需要进一步帮助,请将您用于保存mp3文件的代码放在第一位。
为了便于阅读,存储MP3的代码是这样的..
string alarmfile = "custom.mp3";
isolatedStorageFileStream = new IsolatedStorageFileStream(alarmfile,FileMode.Create,isolatedStorageFile);
long songfilelength = (long) e.Result.Length;
byte[] songbyte = new byte[songfilelength];
e.Result.Read(songbyte, 0, songbyte.Length);
isolatedStorageFileStream.Write(songbyte, 0, songbyte.Length);
isolatedStorageFileStream.Flush();
只有文件打包在XAML可以作为闹钟声音:
备注
Sound URI必须指向打包在应用程序的.xap 文件中的文件。独立存储不受支持。当警报启动时,声音悄悄播放,然后逐渐增加音量。 无法修改此行为。
来源:
您是否尝试过新的URI( “/ custom.mp3”,UriKind.Relative);我不知道这是否会奏效,但值得一试。 – BigL 2011-12-15 10:39:35
/custom.mp3只有在编译时将该文件与您的应用程序一起附加,URI才会起作用。但是,谢谢你的回复:D – 2011-12-27 02:49:01