Carlos Hernandez Perez
Carlos Hernandez Perez

Reputation: 331

Reproduce local video file using XAML and C++

I am currently making a Windows Universal App starting with an Kinect SDK application called CameraFrames. It's a rather complex app but I am having trouble with playing a video from my local files.

To do this, in one of the main windows of my app I insert a MediaPlayerElement in XAML:

        <MediaPlayerElement x:Name="_MediaPlayerElement" AreTransportControlsEnabled="True" HorizontalAlignment="Stretch"  Grid.Row="0"/> 

enter image description here

As shown in the captur above. Below the XAML file I have a cpp file and a header file. I tried searching on the web for a solution to my problem but couldn't find any. It's my first time using XAML thus I don't know how to connect the different objects that I put on my UI to actual code. The ideal result would be to have the ability to choose from my computer which video file I want to reproduce and then display it on this MediaPlayerElement.

Upvotes: 0

Views: 62

Answers (1)

Soonts
Soonts

Reputation: 21936

You should set the Source property of your MediaPlayerElement.

If you want to do that in code, use MediaSource.CreateFromStorageFile or CreateFromStream method to create the media source.

Also, UWP apps run in isolated containers. By design, they can’t access files from arbitrary location of your hard drive. Read this article for more info.

Upvotes: 1

Related Questions