多个WPF MediaElements不能正常工作

时间:2022-09-09 14:12:38

I just want to know why 2 video doesn't work at the same time? Only 1 video plays and the second doesn't. But there is a sound of the second video... That's odd! Any clue? Thanks!

我只是想知道为什么两个视频不能同时播放?只有一个视频播放,第二个没有。但是有第二个视频的声音……这是奇怪的!有线索吗?谢谢!

 <Grid>
        <MediaElement Height="299" HorizontalAlignment="Left" Name="mediaElement1" VerticalAlignment="Top" Width="213" LoadedBehavior="Manual" />
        <MediaElement Height="299" HorizontalAlignment="Left" Margin="231,0,0,0" Name="mediaElement2" VerticalAlignment="Top" Width="260" LoadedBehavior="Manual" />
    </Grid>

UPDATES:

更新:

As I found it works like I said under DEBUG mode of Visual Studio only.

我发现它只在Visual Studio的调试模式下工作。

1 个解决方案

#1


0  

Playing 2 videos in WPF is NOT an issue. How are you loading the videos?

在WPF上播放2个视频不是问题。你是如何加载这些视频的?

    public MainWindow()
    {
        InitializeComponent();

        mediaElement1.Source = new Uri("Content\\Wildlife.wmv", UriKind.Relative);
        mediaElement2.Source = new Uri("Content\\Wildlife.wmv", UriKind.Relative);

        mediaElement1.Play();
        mediaElement2.Play();
    }

Just make sure that the video path is correct.

If you add the the video in your project make sure it has the following properties set:

确保视频路径是正确的。如果您在项目中添加视频,请确保它具有以下属性集:

  • Content
  • 内容
  • Copy if newer
  • 如果新副本

#1


0  

Playing 2 videos in WPF is NOT an issue. How are you loading the videos?

在WPF上播放2个视频不是问题。你是如何加载这些视频的?

    public MainWindow()
    {
        InitializeComponent();

        mediaElement1.Source = new Uri("Content\\Wildlife.wmv", UriKind.Relative);
        mediaElement2.Source = new Uri("Content\\Wildlife.wmv", UriKind.Relative);

        mediaElement1.Play();
        mediaElement2.Play();
    }

Just make sure that the video path is correct.

If you add the the video in your project make sure it has the following properties set:

确保视频路径是正确的。如果您在项目中添加视频,请确保它具有以下属性集:

  • Content
  • 内容
  • Copy if newer
  • 如果新副本