Fixed mediaplayer loop on EOS for both rate directions.

This commit is contained in:
brunoherbelin
2020-07-28 21:52:18 +02:00
parent fd30b742b8
commit 2eb59f2ffe
2 changed files with 10 additions and 11 deletions

View File

@@ -439,6 +439,9 @@ void MediaPlayer::seekNextFrame()
if (!enabled_ || isPlaying())
return;
if ( position_ == ( rate_ < 0.0 ? start_position_ : duration() ) )
rewind();
// step
gst_element_send_event (pipeline_, gst_event_new_step (GST_FORMAT_BUFFERS, 1, ABS(rate_), TRUE, FALSE));
}
@@ -840,7 +843,7 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, MediaPlayer::FrameStatus status)
}
// give a position to EOS
else {
frame_[write_index_].position = duration();
frame_[write_index_].position = rate_ > 0.0 ? duration() : start_position_;
}
// unlock access to frame

View File

@@ -398,20 +398,19 @@ void UserInterface::handleMouse()
//
// RIGHT Mouse button
//
if ( ImGui::IsMouseDragging(ImGuiMouseButton_Right, 10.0f) )
{
// right mouse drag => drag current view
View::Cursor c = Mixer::manager().view()->drag( mouseclic[ImGuiMouseButton_Right], mousepos);
setMouseCursor(io.MousePos, c);
}
else if ( ImGui::IsMouseDown(ImGuiMouseButton_Right)) {
else if ( ImGui::IsMouseDown(ImGuiMouseButton_Right))
{
Mixer::manager().unsetCurrentSource();
navigator.hidePannel();
// glm::vec3 point = Rendering::manager().unProject(mousepos, Mixer::manager().currentView()->scene.root()->transform_ );
}
if ( ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Right) )
{
Mixer::manager().view()->recenter();
@@ -504,7 +503,6 @@ void UserInterface::handleMouse()
// only operate if the view didn't change
if (view_drag == Mixer::manager().view()) {
// action on current source
Source *current = Mixer::manager().currentSource();
if (current)
@@ -1147,7 +1145,7 @@ void MediaController::Render()
float spacing = ImGui::GetStyle().ItemInnerSpacing.x;
if (ImGui::Button(ICON_FA_FAST_BACKWARD))
if (ImGui::Button(mp_->playSpeed() > 0 ? ICON_FA_FAST_BACKWARD :ICON_FA_FAST_FORWARD))
mp_->rewind();
ImGui::SameLine(0, spacing);
@@ -1157,8 +1155,7 @@ void MediaController::Render()
// display buttons Play/Stop depending on current playing mode
if (media_playing_mode_) {
if (ImGui::Button(ICON_FA_PAUSE " Pause"))
if (ImGui::Button(ICON_FA_PAUSE " Pause", ImVec2(100, 0)))
media_playing_mode_ = false;
ImGui::SameLine(0, spacing);
@@ -1168,8 +1165,7 @@ void MediaController::Render()
ImGui::PopButtonRepeat();
}
else {
if (ImGui::Button(ICON_FA_PLAY " Play "))
if (ImGui::Button(mp_->playSpeed() < 0 ? ICON_FA_LESS_THAN " Play": ICON_FA_GREATER_THAN " Play", ImVec2(100, 0)))
media_playing_mode_ = true;
ImGui::SameLine(0, spacing);