Moving functions in Video.cpp

This commit is contained in:
2025-10-27 16:19:57 +02:00
parent 4949ae9b26
commit 4dba7ea911
2 changed files with 40 additions and 40 deletions

View File

@@ -16,6 +16,45 @@
using namespace ChargeVideo; using namespace ChargeVideo;
using namespace _ffmpeg; 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 Construct/Destruct ==================
Video::Video(std::string path, ChargeAudio::Engine *engine, Flags videoF, Video::Video(std::string path, ChargeAudio::Engine *engine, Flags videoF,
float bufferS) float bufferS)
@@ -118,42 +157,3 @@ Video::~Video() {
avcodec_free_context(&vCodecCtx); avcodec_free_context(&vCodecCtx);
avcodec_free_context(&aCodecCtx); 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; }

View File

@@ -32,7 +32,7 @@ void Video::continueVideo() {
clock = clock =
(double)Sound->GetPlayedSampleCount() / audioEngine->GetSampleRate(); (double)Sound->GetPlayedSampleCount() / audioEngine->GetSampleRate();
} else { } else {
clock += Manager::DeltaTime; clock += Manager::DeltaTime; // Internal clock
} }
// Load frame // Load frame