|
@@ -637,68 +637,6 @@ std::pair<std::unique_ptr<ui8 []>, si64> CAudioInstance::extractAudio(const Vide
|
|
|
return dat;
|
|
|
}
|
|
|
|
|
|
-bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & position, bool useOverlay, bool stopOnKey)
|
|
|
-{
|
|
|
- CVideoInstance instance;
|
|
|
-
|
|
|
- auto extractedAudio = getAudio(name);
|
|
|
- int audioHandle = CCS->soundh->playSound(extractedAudio);
|
|
|
-
|
|
|
- if (!instance.openInput(name))
|
|
|
- return true;
|
|
|
-
|
|
|
- instance.openVideo();
|
|
|
- instance.prepareOutput(1, true);
|
|
|
-
|
|
|
- auto lastTimePoint = boost::chrono::steady_clock::now();
|
|
|
-
|
|
|
- while(instance.loadNextFrame())
|
|
|
- {
|
|
|
- if(stopOnKey)
|
|
|
- {
|
|
|
- GH.input().fetchEvents();
|
|
|
- if(GH.input().ignoreEventsUntilInput())
|
|
|
- {
|
|
|
- CCS->soundh->stopSound(audioHandle);
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- SDL_Rect rect;
|
|
|
- rect.x = position.x;
|
|
|
- rect.y = position.y;
|
|
|
- rect.w = instance.dimensions.x;
|
|
|
- rect.h = instance.dimensions.y;
|
|
|
-
|
|
|
- SDL_RenderFillRect(mainRenderer, &rect);
|
|
|
-
|
|
|
- if(instance.textureYUV)
|
|
|
- SDL_RenderCopy(mainRenderer, instance.textureYUV, nullptr, &rect);
|
|
|
- else
|
|
|
- SDL_RenderCopy(mainRenderer, instance.textureRGB, nullptr, &rect);
|
|
|
-
|
|
|
- SDL_RenderPresent(mainRenderer);
|
|
|
-
|
|
|
- // Framerate delay
|
|
|
- double targetFrameTimeSeconds = instance.getCurrentFrameDuration();
|
|
|
- auto targetFrameTime = boost::chrono::milliseconds(static_cast<int>(1000 * targetFrameTimeSeconds));
|
|
|
-
|
|
|
- auto timePointAfterPresent = boost::chrono::steady_clock::now();
|
|
|
- auto timeSpentBusy = boost::chrono::duration_cast<boost::chrono::milliseconds>(timePointAfterPresent - lastTimePoint);
|
|
|
-
|
|
|
- if(targetFrameTime > timeSpentBusy)
|
|
|
- boost::this_thread::sleep_for(targetFrameTime - timeSpentBusy);
|
|
|
-
|
|
|
- lastTimePoint = boost::chrono::steady_clock::now();
|
|
|
- }
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-void CVideoPlayer::playSpellbookAnimation(const VideoPath & name, const Point & position)
|
|
|
-{
|
|
|
- openAndPlayVideoImpl(name, position * GH.screenHandler().getScalingFactor(), false, false);
|
|
|
-}
|
|
|
-
|
|
|
std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, float scaleFactor)
|
|
|
{
|
|
|
auto result = std::make_unique<CVideoInstance>();
|