简体   繁体   English

如何在 wpf 中播放 MP4?

[英]How to play MP4 in wpf?

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"
                          />

Does the video show up at all?视频是否完全显示? Just a hunch, try adding Height="200" Visibility="Visible" to the MediaElement.只是预感,尝试将 Height="200" Visibility="Visible" 添加到 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.应该支持 MP4。

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 .根据文档, LoadedBehavior设置为MediaState.Manual意味着当 System.Windows.Controls.MediaElement 被分配有效的媒体源时,媒体将预滚动但不播放 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM