C# 保存到隔离存储后,如何自动打开(播放)文件?WP8
我认为它应该放在OpenReadCompleted事件中的某个地方,但我尝试过的任何东西都不起作用。下面的代码包括如果文件已经存在,它将播放的部分,这是有效的。但我想它也自动播放后,最初下载C# 保存到隔离存储后,如何自动打开(播放)文件?WP8,c#,windows-phone-8,isolatedstorage,C#,Windows Phone 8,Isolatedstorage,我认为它应该放在OpenReadCompleted事件中的某个地方,但我尝试过的任何东西都不起作用。下面的代码包括如果文件已经存在,它将播放的部分,这是有效的。但我想它也自动播放后,最初下载 audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFiledata.SavePath,FileMode.Open, FileAccess.Read, FileShare.Read); AudioPlayer.Set
audioStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFiledata.SavePath,FileMode.Open, FileAccess.Read, FileShare.Read);
AudioPlayer.SetSource(audioStream);
AudioPlayer.Play();
}
else
{
WebClient client = new WebClient();
client.OpenReadCompleted += (senderClient, args) =>
{
using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))
{
args.Result.Seek(0, SeekOrigin.Begin);
args.Result.CopyTo(fileStream);
}
};
client.OpenReadAsync(new Uri(data.FilePath));
}
我可以发誓我早就试过了,但没用。这是我的解决办法。在参数后添加AudioPlayer代码,如下所示:
using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication).CreateFile(data.SavePath))
{
args.Result.Seek(0, SeekOrigin.Begin);
args.Result.CopyTo(fileStream);
AudioPlayer.SetSource(fileStream);
AudioPlayer.Play();
我可以发誓我早就试过了,但没用。这是我的解决办法。在参数后添加音频播放器代码,如:
使用(IsolatedStorageFileStream fileStream=IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath)){args.Result.Seek(0,SeekOrigin.Begin);args.Result.CopyTo(fileStream);AudioPlayer.SetSource(文件流);AudioPlayer.Play();