Pergunta

What am I trying?

I am trying to load a quicktime movie from the Video Library like this:

async void SetupVideoAsyncAndPlay() {
    StorageFolder folder = 
               await KnownFolders.VideosLibrary.GetFolderAsync("Video Folder");
    StorageFile file = await folder.GetFileAsync("test_video.mov");

    // Ensure a file was selected
    if (file != null) {
        var fileStream = 
                await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);

        Video.SetSource(fileStream, file.ContentType);
        Video.Play();
    }
}

What have I tried?

I have come to this after a lot of digging. First I had the Windows.Storage.FileAccessMode.ReadWrite to only Read and didn't fire any event. Now, it fires the MediaFailed Event (registered it using Video.MediaOpened += RightVideo_MediaOpened;)

In the MediaFailed Event I get the following:

ErrorMessage = "MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED : HRESULT - 0xC00D36C4"

I have the MediaElement in the Visual Tree (one of the possible problems) since I declare this element in the XAML.

Additionally, I have tried to run the same video without the filestream (directly from the application bundle) and it works.

Also, if I replace the StorageFile/FileStream code by a Picker it works :

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.FileTypeFilter.Add(".mov");
StorageFile file = await openPicker.PickSingleFileAsync();
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

Note that I gave permissions in the Package.appmanifest for the Video folder.

Foi útil?

Solução

When are you calling SetupVideoAsyncAndPlay? I remember having the same problem and resolved it by making sure that the MediaElement initialization is only done after it has been loaded into the VisualTree (after receiving the Loaded event).

Hope that helps.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top