Home > Software engineering >  How to play MP4 in wpf?
How to play MP4 in wpf?

Time:01-27

the most I managed so far was to reproduce the sound, without image

<MediaElement Name="myMediaElement" LoadedBehavior="Manual"
                          Margin="5"
                          Grid.Row="0"
                          Grid.Column="0"
                          ScrubbingEnabled="True"
                          Source="C:\Users\TheMagicTool Server\Downloads\myVideo.mp4"
                          />

CodePudding user response:

Does the video show up at all? Just a hunch, try adding Height="200" Visibility="Visible" to the MediaElement.

<MediaElement Name="myMediaElement" LoadedBehavior="Manual"
                      Height="200" 
                      Visibility="Visible"
                      Margin="5"
                      Grid.Row="0"
                      Grid.Column="0"
                      ScrubbingEnabled="True"
                      Source="C:\Users\TheMagicTool Server\Downloads\myVideo.mp4"
                      />

Not sure if this'll help at all but worth a shot. MP4 should be supported.

CodePudding user response:

According to the documentation the LoadedBehavior set to MediaState.Manual means that media will preroll but not play when the System.Windows.Controls.MediaElement is assigned valid media source. Therefore start from the minimal parameters set:

<Window ...
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    Title="MainWindow" Height="450" Width="800">
    <Grid>
        <MediaElement Source="C:\Users\TheMagicTool Server\Downloads\myVideo.mp4" />
    </Grid>
</Window>
  •  Tags:  
  • Related