locked
video source of what a user selected?

    Question

  • HELP!!! Stuck :-/

    I need help with selecting a video and using that videos source in the media element?

    I have managed to do it for pictures like this;

    Private Async Sub OpenPic_Click(sender As Object, e As RoutedEventArgs) Handles OpenPic.Click
            Dim openpicker = New Windows.Storage.Pickers.FileOpenPicker()
    
            openpicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary
    
            openpicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail
    
    
            ' Filter File Types
            openpicker.FileTypeFilter.Clear()
            openpicker.FileTypeFilter.Add(".bmp")
            openpicker.FileTypeFilter.Add(".png")
            openpicker.FileTypeFilter.Add(".jpg")
            openpicker.FileTypeFilter.Add(".jpeg")
    
            'Open file picker
    
            Dim file = Await openpicker.PickSingleFileAsync
    
            'file = null if user cancels
    
            If file IsNot Nothing Then
                ' open uup a stream for a selected file type
                Dim filestream = Await file.OpenAsync(Windows.Storage.FileAccessMode.Read)
    
                'set image souce to selected bitmap image within the file open picker
                Dim bitmap = New Windows.UI.Xaml.Media.Imaging.BitmapImage()
    
                bitmap.SetSource(filestream)
                displayImage.source = bitmap
    
                Me.DataContext = file
            End If
        End Sub

    however... when doing this;

    Dim bitmap = New Windows.UI.Xaml.Media.Imaging.BitmapImage()

    I want to be able to make it a video not an image...?

    Any Help will be great thank you

    Jordan



    Tuesday, February 25, 2014 7:44 PM

Answers

  • Hi, it is a windows store app question, it is better to ask it in windows store forum. 

    Source of MediaElement is a Uri, you don't need to read the video file to a stream, for example, you can use below code 

    element.Source = New Uri(fileName)

    Wednesday, February 26, 2014 5:10 AM

All replies

  • Hi,

     Please edit your post and add your code by copying it from the VB code window and then pasting it in a Code Block. You will see the button at the top of the editor like the picture below. I can`t even see your text because it blends in with the page color.

    • Edited by IronRazerz Tuesday, February 25, 2014 9:12 PM
    Tuesday, February 25, 2014 9:11 PM
  • There you go, sorry about that

    Tuesday, February 25, 2014 9:16 PM
  • Hi, it is a windows store app question, it is better to ask it in windows store forum. 

    Source of MediaElement is a Uri, you don't need to read the video file to a stream, for example, you can use below code 

    element.Source = New Uri(fileName)

    Wednesday, February 26, 2014 5:10 AM
  • Hi PayneApplications,

    A documentation for you: Quickstart: video and audio and How to open media files using the FileOpenPicker control

     if (null != file)
        {
            mediaControl.SetSource(stream, file.ContentType);
            // mediaControl is a MediaElement defined in XAML
            mediaControl.Play();
        }
    Hope this helps.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" 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.


    Wednesday, February 26, 2014 7:57 AM
    Moderator
  • Thank you verry much! this worked!!
    Wednesday, February 26, 2014 11:20 AM