From 1043283e535a3870b557ef428223a99e9e3b5be5 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 31 Aug 2012 22:06:56 -0400 Subject: PEGASUS: Use setEndTime() --- engines/pegasus/movie.cpp | 17 +++++++++++++++-- engines/pegasus/movie.h | 2 ++ engines/pegasus/pegasus.cpp | 5 ++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp index fc722e5043..6187d87a2d 100644 --- a/engines/pegasus/movie.cpp +++ b/engines/pegasus/movie.cpp @@ -81,7 +81,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent) allocateSurface(bounds); setStart(0, getScale()); - setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale()); + TimeBase::setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale()); } void Movie::redrawMovieWorld() { @@ -132,6 +132,13 @@ void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) { _movieBox.moveTo(h, v); } +void Movie::setStop(const TimeValue stopTime, const TimeScale scale) { + TimeBase::setStop(stopTime, scale); + + if (_video) + _video->setEndTime(Audio::Timestamp(0, _stopTime, _stopScale)); +} + void Movie::setVolume(uint16 volume) { if (_video) _video->setVolume(MIN(volume, 0xFF)); @@ -205,12 +212,18 @@ TimeValue Movie::getDuration(const TimeScale scale) const { void Movie::updateTime() { // The reason why we overrode TimeBase's updateTime(): // Again, avoiding timers and handling it here - if (_video && !_video->isPaused()) { + if (_video && _video->isPlaying() && !_video->isPaused()) { redrawMovieWorld(); uint32 startTime = _startTime * getScale() / _startScale; uint32 stopTime = _stopTime * getScale() / _stopScale; uint32 actualTime = CLIP(_video->getTime() * getScale() / 1000, startTime, stopTime); + + // HACK: Due to the inaccuracy of the time, we won't actually allow us to hit + // the stop time unless we've actually reached the end of the segment. + if (actualTime == stopTime && !_video->endOfVideo()) + actualTime--; + _time = Common::Rational(actualTime, getScale()); } } diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h index efe4a7c244..9b9cc2bdbe 100644 --- a/engines/pegasus/movie.h +++ b/engines/pegasus/movie.h @@ -62,6 +62,8 @@ public: virtual void moveMovieBoxTo(const CoordType, const CoordType); + virtual void setStop(const TimeValue, const TimeScale = 0); + virtual TimeValue getDuration(const TimeScale = 0) const; // *** HACK ALERT diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index efa57d586f..423d321fe0 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -2087,15 +2087,14 @@ void PegasusEngine::playEndMessage() { } void PegasusEngine::doSubChase() { - static const uint32 endTime = 133200 * 1000 / 600; - Video::VideoDecoder *video = new Video::QuickTimeDecoder(); if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie")) error("Failed to load sub chase"); + video->setEndTime(Audio::Timestamp(0, 133200, 600)); video->start(); - while (!shouldQuit() && !video->endOfVideo() && video->getTime() < endTime) { + while (!shouldQuit() && !video->endOfVideo()) { if (video->needsUpdate()) { const Graphics::Surface *frame = video->decodeNextFrame(); -- cgit v1.2.3