多个 WPF MediaElement 无法正常工作

发布于 2024-12-15 04:31:45 字数 515 浏览 2 评论 0原文

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

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

更新:

我发现它的工作原理就像我所说的那样,仅在 Visual Studio 的调试模式下。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁我热情 2024-12-22 04:31:45

在 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();
    }

只需确保视频路径正确即可。

如果您在项目中添加视频,请确保它设置了以下属性:

  • 内容
  • 如果较新,则复制

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

    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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文