how do i open and play a video with FileOpenPicker? RRS feed

  • Question

  • ok, I have my media Element and I have the code to open the file, but how to I put that source to the media element similer to this...


    bitmap = NewWindows.UI.Xaml.Media.Imaging.BitmapImage()

    but obviously I want it for a video..? thank you in advance


    Tuesday, February 25, 2014 8:00 PM


  • Hi,

    There is a simple sample you can refer to:

    In XAML, Create a MediaElement object and give it a Name:

    <MediaElement Name="mediaControl" Height="400" />

    And in code-behind ,use the FileOpenPicker class to select a media file, then to set the Source of the MediaElement to the StorageFile returned from the FileOpenPicker:

    Private Sub SetLocalMedia()
    	Dim openPicker = New Windows.Storage.Pickers.FileOpenPicker()
    	Dim file = Await openPicker.PickSingleFileAsync()
    	Dim stream = Await file.OpenAsync(Windows.Storage.FileAccessMode.Read)
    	If file IsNot Nothing Then
    		mediaControl.SetSource(stream, file.ContentType)
    	End If
    End Sub

    Also, refer to the links below to get more information:

    How to open local media files using the FileOpenPicker control

    Accessing files with file pickers

    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Edited by Anne Jing Wednesday, February 26, 2014 3:15 AM edit
    • Marked as answer by Anne Jing Wednesday, March 5, 2014 9:36 AM
    Wednesday, February 26, 2014 3:14 AM