简体   繁体   English

如何通过URI(WP7)访问IsolatedStorage中下载的声音?

[英]How to access downloaded sound in IsolatedStorage via URI (WP7)?

I basically downloaded a file name custom.mp3 into my isolatedstorage and I can see it via isolatedstorage explorer.... 我基本上将文件名custom.mp3下载到我的isolatedstorage中,并且可以通过isolatedstorage Explorer看到它。

The question here is... How can I access the particular custom.mp3 via URI? 这里的问题是...如何通过URI访问特定的custom.mp3?

So far I got this.. but I wonder why it is not working: 到目前为止,我已经知道了..但是我不知道为什么它不起作用:

alarm.Sound = new Uri("isostore:/custom.mp3", UriKind.Absolute);

Only files packaged in the XAML can be used as alarm sound: 仅XAML中打包的文件可以用作警报声音:

Remarks 备注

The Sound URI must point to a file packaged in the application's .xap file. 声音URI必须指向应用程序.xap文件中打包的文件。 Isolated storage is not supported. 不支持隔离存储。 When the alarm is launched, the sound is played quietly and then gradually increases in volume. 发出警报时,声音会安静地播放,然后逐渐增加音量。 There is no way to modify this behavior. 无法修改此行为。

From: 从:

Alarm.Sound Property Alarm.Sound属性

Your path is wrong. 您的路线是错误的。 Nothing else is wrong with your code. 您的代码没有其他问题。 Post the code you're using for saving the mp3 file in the first place, if you want further help. 如果您需要进一步的帮助,请首先发布用于保存mp3文件的代码。

For easier reading, the code to store the MP3 goes something like this.. 为了便于阅读,存储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();

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM