同时播放两个视频 [英] playing two videos simultaneously

查看:45
本文介绍了同时播放两个视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用中同时循环播放两个视频(每个长度为 15 秒).有时我需要更改一个视频(在 DoubleAnimation 中)的不透明度,让它出现在另一个视频上方.播放两个视频需要同步.

I need to play cyclically two videos (each is 15 seconds length) simultaneously in my app. And time by time I need to change opacity of one video (in DoubleAnimation), to let it appear above another video. Playing two videos need for syncronization purposes.

我尝试使用 MediaElements 播放视频,但无法让它们同时播放视频.我认为这是不可能的.我说得对吗?

I tried to use MediaElements to play video, but I can not get them to play the video simultaneously. I think it's impossible. Am I right?

我还尝试将视频分成 450 帧(每秒 30 帧)并使用 ObjectAnimationUsingKeyFrames,(例如:http://compiledexperience.com/windows-phone/tutorials/candle),但是这种方式使用了太多内存(已用内存约为 250 MB,但最大使用量必须为 90 MB).

Also I tried to divide my videos into 450 frames (30 frames per second) and use ObjectAnimationUsingKeyFrames, (example: http://compiledexperience.com/windows-phone/tutorials/candle), but this way uses too many memory (used memory is about 250 MB, though the maximum usage must be 90 MB).

最后我尝试使用 DispatcherTimer 并在它的 Tick 程序中更改两个图像的源属性,但它的工作速度足够慢.

At last I tried to use DispatcherTimer and in it's Tick procedure change the Source Properties of two Images, but it works slow enough.

请帮帮我,有没有办法做到这一点而没有滞后?

Help me please, is there any way to do this without lags?

推荐答案

另一种选择是尝试使用 CompositionTarget.Rendering如此处所述:http://msdn.microsoft.com/en-us/library/ms748838.aspx

Another option would be try using CompositionTarget.Rendering as described here: http://msdn.microsoft.com/en-us/library/ms748838.aspx

您可能遇到的问题是无法保证调用之间的时间间隔,因此您可能会使帧运行得更快或更慢.

The problem you may run into is that the time between calls is not guaranteed and so you may get frames running faster or slower.

然而,Charles Petzold 有一篇博文展示了如何确定经过的时间,这样您就可以在 Rendering 事件发生时选择要显示的正确帧.示例代码应该会有所帮助:http://www.charlespetzold.com/blog/2010/06/CompositionTarget-Rendering-and-RenderEventArgs.html

However Charles Petzold has a post showing how to determine the time elapsed in a manner that would allow you to pick the correct frame to display whenever the Rendering event happens. The example code should be helpful: http://www.charlespetzold.com/blog/2010/06/CompositionTarget-Rendering-and-RenderEventArgs.html

这篇关于同时播放两个视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆