问题
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.
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?
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).
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?
回答1:
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.
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
来源:https://stackoverflow.com/questions/10073433/playing-two-videos-simultaneously