From 4dba7ea911b9c30de4db315e613ae04c9982cbda Mon Sep 17 00:00:00 2001 From: cat Date: Mon, 27 Oct 2025 16:19:57 +0200 Subject: [PATCH] Moving functions in Video.cpp --- src/Video.cpp | 78 ++++++++++++++++++++--------------------- src/VideoProcessing.cpp | 2 +- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Video.cpp b/src/Video.cpp index 7c312ff..05b65ea 100644 --- a/src/Video.cpp +++ b/src/Video.cpp @@ -16,6 +16,45 @@ using namespace ChargeVideo; using namespace _ffmpeg; +// ================== Public Video Controls ================== +void Video::AdvanceToNextFrame() { loadTexture(loadNextFrame().second); } + +void Video::Play() { + if (ID != 0) { + return; + } + ID = Manager::hookVideo(std::bind(&Video::continueVideo, this)); + reinitSound(); + if (audioStreamNum != -1) { + Sound->Play(); + } + videoState = State::Playing; +} + +void Video::Pause() { + if (ID == 0) { + return; + } + Manager::unhookVideo(ID); + reinitSound(); + ID = 0; + videoState = State::Paused; +} + +void Video::Restart() { + if (ID == 0) { + Play(); + } + restartVideo(); +} + +const double Video::GetDuration() { return timeBase * videoStream->duration; } +const double Video::GetPlaybackTime() { return clock; } +const Vector2i Video::GetDimensions() { return Dimensions; } +Video::State Video::GetState() { return videoState; } +Video::Flags Video::GetFlags() { return videoFlags; } +void Video::SwitchLooping() { videoFlags = videoFlags ^ Flags::Looping; } + // ================== Video Construct/Destruct ================== Video::Video(std::string path, ChargeAudio::Engine *engine, Flags videoF, float bufferS) @@ -118,42 +157,3 @@ Video::~Video() { avcodec_free_context(&vCodecCtx); avcodec_free_context(&aCodecCtx); } - -// ================== Public Video Controls ================== -void Video::AdvanceToNextFrame() { loadTexture(loadNextFrame().second); } - -void Video::Play() { - if (ID != 0) { - return; - } - ID = Manager::hookVideo(std::bind(&Video::continueVideo, this)); - reinitSound(); - if (audioStreamNum != -1) { - Sound->Play(); - } - videoState = State::Playing; -} - -void Video::Pause() { - if (ID == 0) { - return; - } - Manager::unhookVideo(ID); - reinitSound(); - ID = 0; - videoState = State::Paused; -} - -void Video::Restart() { - if (ID == 0) { - Play(); - } - restartVideo(); -} - -const double Video::GetDuration() { return timeBase * videoStream->duration; } -const double Video::GetPlaybackTime() { return clock; } -const Vector2i Video::GetDimensions() { return Dimensions; } -Video::State Video::GetState() { return videoState; } -Video::Flags Video::GetFlags() { return videoFlags; } -void Video::SwitchLooping() { videoFlags = videoFlags ^ Flags::Looping; } diff --git a/src/VideoProcessing.cpp b/src/VideoProcessing.cpp index 960793b..98f266d 100644 --- a/src/VideoProcessing.cpp +++ b/src/VideoProcessing.cpp @@ -32,7 +32,7 @@ void Video::continueVideo() { clock = (double)Sound->GetPlayedSampleCount() / audioEngine->GetSampleRate(); } else { - clock += Manager::DeltaTime; + clock += Manager::DeltaTime; // Internal clock } // Load frame