Windows 8 app - MediaElement not playing “.wmv” files

前端 未结 1 1923
一个人的身影
一个人的身影 2020-12-20 03:52

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

相关标签:
1条回答
  • 2020-12-20 03:52

    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.

    0 讨论(0)
提交回复
热议问题