From a8a99a628f6f3bc8ddefec8dfae8a7aa27b8f863 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 7 Feb 2010 19:18:00 +0000 Subject: BGE: add audio/video synchronization capability to VideoTexture Add optional parameter to VideoTexture.Texture refresh() method to specify timestamp (in seconds from start of movie) of the frame to be loaded. This value is passed down to image source and for VideoFFmpeg source, it is used instead of current time to load the frame from the video file. When combined with an audio actuator, it can be used to synchronize the sound and the image: specify the same video file in the sound actuator and use the KX_SoundActuator time attribute as timestamp to refresh: the frame corresponding to the sound will be loaded: GameLogic.video.refresh(True, soundAct.time) --- source/gameengine/VideoTexture/ImageBase.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/gameengine/VideoTexture/ImageBase.cpp') diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 0740afed2c6..1c5425c932c 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -71,7 +71,7 @@ bool ImageBase::release (void) // get image -unsigned int * ImageBase::getImage (unsigned int texId) +unsigned int * ImageBase::getImage (unsigned int texId, double ts) { // if image is not available if (!m_avail) @@ -82,12 +82,12 @@ unsigned int * ImageBase::getImage (unsigned int texId) // get images from sources for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) // get source image - (*it)->getImage(); + (*it)->getImage(ts); // init image init(m_sources[0]->getSize()[0], m_sources[0]->getSize()[1]); } // calculate new image - calcImage(texId); + calcImage(texId, ts); } // if image is available, return it, otherwise NULL return m_avail ? m_image : NULL; @@ -305,12 +305,12 @@ void ImageSource::setSource (PyImage * source) // get image from source -unsigned int * ImageSource::getImage (void) +unsigned int * ImageSource::getImage (double ts) { // if source is available if (m_source != NULL) // get image from source - m_image = m_source->m_image->getImage(); + m_image = m_source->m_image->getImage(0, ts); // otherwise reset buffer else m_image = NULL; -- cgit v1.2.3