Windows 8应用 - 的MediaElement不玩" .WMV"档 [英] Windows 8 app - MediaElement not playing ".wmv" files
问题描述
我有的MediaElement
的一个问题在我的Win8应用程序 - 当我试图从它经常(并不总是)引发当地图书馆玩一些.WMV文件的MediaFailed
和我得到的错误
I have an issue with MediaElement
in my Win8 app - when I try to play some ".wmv" files from local library it very often (not always) throws MediaFailed
and I get the error
MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED:HRESULT - 0xC00D36C4
MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED : HRESULT - 0xC00D36C4
这意味着
无论是视频编解码器或音频编解码器是不支持的,或
在视频文件中的流中的一个已损坏。此内容可能不支持
Either the video codec or the audio codec is unsupported, or one of the streams in a video file is corrupted. This content may not be supported.
问题是的不的那个文件被损坏(我可以用Windows Media Player播放他们)。下面是我用来设置的MediaElement
中的代码:
The problem is not that files are corrupted (I can play them with Windows Media Player). Here's the code I use to set MediaElement
:
private async void Button_Click(object sender, RoutedEventArgs e)
{
var picker = new FileOpenPicker();
picker.FileTypeFilter.Add(".wmv");
picker.FileTypeFilter.Add(".mp4");
picker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
StorageFile file = await picker.PickSingleFileAsync();
if (file != null)
{
using (IRandomAccessStream ras = await file.OpenAsync(FileAccessMode.Read))
{
me.SetSource(ras, file.ContentType);
}
}
}
有谁知道什么是错在这里?先谢谢了。
Does anybody know what's wrong here? Thanks in advance.
推荐答案
这个问题可能是你在玩它之前关闭流。因此,此代码:(!文件= NULL)
The problem is likely that you are closing the stream prior to playing it. Therefore this code:
if (file != null)
{
using (IRandomAccessStream ras = await file.OpenAsync(FileAccessMode.Read))
{
me.SetSource(ras, file.ContentType);
}
// The stream is now closed! How can it be played!?
}
应该改为使用没有code>块:
if (file != null)
{
IRandomAccessStream ras = await file.OpenAsync(FileAccessMode.Read);
me.SetSource(ras, file.ContentType);
}
我曾尝试上面的一些频道9视频代码的第二块(包括中,高品质的WMV文件)和我的应用程序发挥他们的成功。
I did try the second block of code above on some channel 9 videos (both mid and high quality wmv files) and my app played them successfully.
这篇关于Windows 8应用 - 的MediaElement不玩" .WMV"档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!