我与访问声音文件(MP3)下载独立存储中的这个问题挣扎在报警使用,如何通过URI(WP8)访问IsolatedStorage中下载的声音?
问题提到before
我收到此错误:
BNS错误:动作请求的声音uri无效
请帮助我,但请记住我正在使用闹钟的声音文件 关于代码,它与上面的链接相同。
这是下载并保存声音文件的代码:
Public Async Function DownloadFile(url As Uri) As Task(Of Stream)
wc = New WebClient()
AddHandler wc.OpenReadCompleted, AddressOf OpenReadCompleted
AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgress
wc.OpenReadAsync(url)
Dim r As IO.Stream = Await tcs.Task
Return r
End Function
Private Sub OpenReadCompleted(sender As Object, e As OpenReadCompletedEventArgs)
If e.[Error] IsNot Nothing Then
tcs.TrySetException(e.[Error])
ElseIf e.Cancelled Then
tcs.TrySetCanceled()
Else
tcs.TrySetResult(e.Result)
Dim file As IsolatedStorageFile
file = IsolatedStorageFile.GetUserStoreForApplication()
Using Stream As IsolatedStorageFileStream = New IsolatedStorageFileStream("Sound.mp3", System.IO.FileMode.Create, file)
Dim buffer As Byte() = New Byte(1023) {}
While (e.Result.Read(buffer, 0, buffer.Length) > 0)
Stream.Write(buffer, 0, buffer.Length)
End While
End Using
End If
End Sub
Private Sub DownloadProgress(sender As Object, e As DownloadProgressChangedEventArgs)
Proind.Value = e.ProgressPercentage/100
Proind.Text = e.ProgressPercentage.ToString & " %" & " (" & (e.BytesReceived \ 1000).ToString & "/" & (e.TotalBytesToReceive \ 1000).ToString & ") KB"
End Sub
搜索:报警作为'alarm.Sound =新的URI( “/共享/传输/ custom.mp3”,UriKind.Relative);' – anderZubi
试了一下,没有工作给了我同样的错误。 –
演示如何下载并保存歌曲 – anderZubi