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
which means
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.
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.
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!?
}
should be changed to not have the using
block:
if (file != null)
{
IRandomAccessStream ras = await file.OpenAsync(FileAccessMode.Read);
me.SetSource(ras, file.ContentType);
}
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.
User contributions licensed under CC BY-SA 3.0