从 wp7 中的独立存储流式传输视频

发布于 2024-10-05 08:04:09 字数 807 浏览 0 评论 0原文

我正在尝试制作一些 wp7 应用程序,它应该从服务器播放视频。 该应用程序的功能之一是下载选定的视频并从独立存储中播放它们。

我正在使用下一个代码进行下载:

WebClient wc = new WebClient();
wc.OpenReadCompleted += (s, a) => { /* saving result stream to isolated storage */}
wc.OpenReadAsync(fileUri);

所以,当我单击播放按钮时,我检查文件是否已下载,如果是,我打开该文件的isolatedStorageFileStream并将其设置为播放器的源,否则我设置为源文件乌里。

问题是,当我尝试将isolatedStorageFileStream 设置为 MedialElement 的源时,出现 MediaFailed 异常。有人可以帮我吗?

代码看起来像下一种方式

private IsolatedStorageFile isf;
private IsolatedStorageFileStream stream;

private void playButton_Click(..)
{
isf = IsolatedStorageFile.GetUserStoreForApplication();
stream = isf.OpenFile(path, FileMode.Open);
MediaPlayer.SetSource(stream);
MediaPlayer.Play();
}

Stream 没有损坏,它的长度是正确的。我真的不知道该怎么办。 提前致谢

I'm trying to make some wp7 app which should play videos from server.
One of the app's features is downloading selected videos and playing them from isolated storage.

I'm using next code for downloading:

WebClient wc = new WebClient();
wc.OpenReadCompleted += (s, a) => { /* saving result stream to isolated storage */}
wc.OpenReadAsync(fileUri);

So, when I click on play button, I check if file was downloaded or not, and if it was I open IsolatedStorageFileStream for this file and set it to player's source, otherwise I set to source file Uri.

Problem is that I get MediaFailed exception when I'm trying to set IsolatedStorageFileStream as MedialElement's source. Can anybody help me with it?

Code looks like in next way

private IsolatedStorageFile isf;
private IsolatedStorageFileStream stream;

private void playButton_Click(..)
{
isf = IsolatedStorageFile.GetUserStoreForApplication();
stream = isf.OpenFile(path, FileMode.Open);
MediaPlayer.SetSource(stream);
MediaPlayer.Play();
}

Stream is not corrupted, its length is correct. I realy don't know what to do with it.
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

纸短情长 2024-10-12 08:04:11

我找到了解决方案,这很奇怪,但有效

问题是我保存名称为 %clipId%.clip 的文件,但是当我将文件名更改为 %clipId%.mp4 (我的剪辑以 mp4 编码)时,它就可以工作了!!!

无法理解为什么会这样。

I've found solution, it's very strange, but works

The problem was that I save files with names %clipId%.clip, but when I changed file names to %clipId%.mp4 (my clips are encoded in mp4) it becomes work!!!

Can't understand why it is so.

小清晰的声音 2024-10-12 08:04:11

媒体播放器查看文件名以检查它是否支持该格式。 “.clip”不是有效的格式。

The media player looks at the filename to check if it supports the format. ".clip" is no valid format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文