none
WPF Media Element Doesn't Load Video RRS feed

  • Question

  • Hi Guys,

    I'm doing a school project and I need to play a video in a Media Element. I have setup the media element in XAML like this:

        <Grid>
            <MediaElement Name="VideoControl" Width="200" Height ="400" Source="Resources/What Most Schools Don't Teach.mp4" LoadedBehavior="Play"/>
        </Grid>

    In the designer, it loads and has a black screen like it's going to play something, but when I load it in a test run, it sits bank in the window and does nothing. I specifically set the Loaded behavior to play because I don't want a play button. I have put the ".mp4" file into the resources folder. I set the source to aim at that resource file folder location.

    1. How can I have the Media Element play the video specified in the source when the WPF window initially loads?


    Whutchison


    • Edited by SkyeRanger Wednesday, December 3, 2014 11:15 PM Slight information addition
    Wednesday, December 3, 2014 11:13 PM

Answers

  • Hi SkyeRanger,

    You have to make sure that your video file has the correct content type and copy settings:

    1. Right click your video file in the solution explorer and chose properties.
    2. Make sure Build Action is set to "Content"
    3. Make sure Copy to output is set to "Copy Always" or "Copy if Newer"

    That should fix it.

    Background:

    At runtime the video file must be in ..\bin\Debug\Resources\*.mp4.

    And this only happens of copy is set as in step 3 above.

    Rgds MM

    PS: Don't forget to "mark as anser" if this post was helpful to you. Thanks!

    • Marked as answer by SkyeRanger Thursday, December 4, 2014 12:40 AM
    Thursday, December 4, 2014 12:25 AM

All replies

  • Hi SkyeRanger,

    You have to make sure that your video file has the correct content type and copy settings:

    1. Right click your video file in the solution explorer and chose properties.
    2. Make sure Build Action is set to "Content"
    3. Make sure Copy to output is set to "Copy Always" or "Copy if Newer"

    That should fix it.

    Background:

    At runtime the video file must be in ..\bin\Debug\Resources\*.mp4.

    And this only happens of copy is set as in step 3 above.

    Rgds MM

    PS: Don't forget to "mark as anser" if this post was helpful to you. Thanks!

    • Marked as answer by SkyeRanger Thursday, December 4, 2014 12:40 AM
    Thursday, December 4, 2014 12:25 AM
  • Thanks this fixed it! Now I've finished my project. I had Step 1 & 2 correct, I was just missing 3.

    Whutchison

    Thursday, December 4, 2014 12:41 AM