Update MediaPlayer and SourceControlWindow to utilize paused time for flag operations and manage loop status

This commit is contained in:
brunoherbelin
2025-11-10 23:09:15 +01:00
parent 17699297f3
commit 7526a43cf0
2 changed files with 15 additions and 5 deletions

View File

@@ -77,6 +77,7 @@ MediaPlayer::MediaPlayer()
position_ = GST_CLOCK_TIME_NONE;
loop_ = LoopMode::LOOP_REWIND;
loop_status_ = LoopStatus::LOOP_STATUS_DEFAULT;
flag_status_ = LoopStatus::LOOP_STATUS_DEFAULT;
fading_mode_ = FadingMode::FADING_COLOR;
// start index in frame_ stack
@@ -1121,6 +1122,7 @@ bool MediaPlayer::go_to(GstClockTime pos)
GstClockTime jumpPts = pos;
// jump in a gap
if (timeline_.getGapAt(pos, gap)) {
// if in a gap, find closest seek target
if (gap.is_valid()) {
@@ -1132,6 +1134,12 @@ bool MediaPlayer::go_to(GstClockTime pos)
if (ABS_DIFF (position_, jumpPts) > 2 * timeline_.step() ) {
ret = true;
seek( jumpPts );
// timeline flags for target jump position
if (timeline_.flagTypeAt(jumpPts) == LoopStatus::LOOP_STATUS_BLACKOUT)
loop_status_ = flag_status_ = LoopStatus::LOOP_STATUS_BLACKOUT;
else
loop_status_ = flag_status_ = LoopStatus::LOOP_STATUS_DEFAULT;
}
}
return ret;

View File

@@ -2292,21 +2292,23 @@ void SourceControlWindow::RenderMediaPlayer(MediaSource *ms)
// flag buttons
if ( !mediaplayer_mode_ && mediaplayer_active_->timeline()->numFlags() > 0 ) {
GstClockTime _paused_time = mediaplayer_active_->position();
ImGui::SameLine(0, h_space_);
if( ImGuiToolkit::ButtonIcon(3, 0, "Go to next flag") ){
// find next flag and go to its midpoint
TimeInterval next_flag = mediaplayer_active_->timeline()->getNextFlag( mediaplayer_active_->position() );
TimeInterval next_flag = mediaplayer_active_->timeline()->getNextFlag( _paused_time );
if ( next_flag.is_valid() )
mediaplayer_active_->go_to( next_flag.midpoint() );
mediaplayer_active_->go_to( next_flag.begin );
}
// if stopped at a flag, show flag type editor
if (mediaplayer_active_->timeline()->isFlagged( mediaplayer_active_->position() )) {
if (mediaplayer_active_->timeline()->isFlagged( _paused_time )) {
static int current_flag = 0;
current_flag = mediaplayer_active_->timeline()->flagTypeAt( mediaplayer_active_->position() );
current_flag = mediaplayer_active_->timeline()->flagTypeAt( _paused_time );
ImGui::SameLine(0, h_space_);
if ( ImGuiToolkit::IconMultistate(icons_flags, &current_flag, tooltips_flags) ){
mediaplayer_active_->timeline()->setFlagTypeAt( mediaplayer_active_->position(), current_flag );
mediaplayer_active_->timeline()->setFlagTypeAt( _paused_time, current_flag );
oss << ": Flag type changed";
Action::manager().store(oss.str());
}