[英]How do you Automatically open(play) file after it is saved to isolation storage? WP8
我认为它应该在OpenReadCompleted事件中的某个地方,但是我尝试过的任何方法都没有用。 下面的代码包括文件已存在的部分,它将播放,此部分起作用。 但我希望它在最初下载后也能自动播放。
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));
}
我本可以发誓早些尝试过,但没有成功。 这是我的解决方案。 在args之后添加了AudioPlayer代码,如下所示:
using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication).CreateFile(data.SavePath))
{
args.Result.Seek(0, SeekOrigin.Begin);
args.Result.CopyTo(fileStream);
AudioPlayer.SetSource(fileStream);
AudioPlayer.Play();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.