2011-12-15 37 views
0

我基本上下載了一個文件名custom.mp3到我的isolationstorage中,我可以通過isolationstorage explorer來查看它....如何通過URI(WP7)訪問IsolatedStorage中下載的聲音?

這裏的問題是...如何通過URI訪問特定的custom.mp3?

到目前爲止,我得到了這個..但我不知道爲什麼它不工作:

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

您是否嘗試過新的URI( 「/ custom.mp3」,UriKind.Relative);我不知道這是否會奏效,但值得一試。 – BigL 2011-12-15 10:39:35

+0

/custom.mp3只有在編譯時將該文件與您的應用程序一起附加,URI纔會起作用。但是,謝謝你的回覆:D – 2011-12-27 02:49:01

回答

0

你的道路是錯誤的。你的代碼沒有其他錯誤。如果您需要進一步幫助,請將您用於保存mp3文件的代碼放在第一位。

0

爲了便於閱讀,存儲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(); 
0

只有文件打包在XAML可以作爲鬧鐘聲音:

備註

Sound URI必須指向打包在應用程序的.xap 文件中的文件。獨立存儲不受支持。當警報啓動時,聲音悄悄播放,然後逐漸增加音量。 無法修改此行爲。

來源:

Alarm.Sound Property