From d04a3681aad20c486c289ee968656cbe0e00bfaf Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Thu, 31 May 2018 15:06:25 +0200 Subject: Fix an issue where looping animations stopped themselves Now we use a fuzzy compare to see if we are within 0.1 ms of the end of a slide, as we don't receive another position update if we are already so close to the end. Change-Id: Ie2c021be00d5a7bdac5fa632c39969bb45c0a2d5 Reviewed-by: Christian Stromme --- src/runtime/q3dsslideplayer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/runtime/q3dsslideplayer.cpp b/src/runtime/q3dsslideplayer.cpp index 2db55f3..0388ab1 100644 --- a/src/runtime/q3dsslideplayer.cpp +++ b/src/runtime/q3dsslideplayer.cpp @@ -728,9 +728,17 @@ void Q3DSSlidePlayer::sendPositionChanged(Q3DSSlide *slide, float pos) if (!qFuzzyCompare(oldPosition, pos)) Q_EMIT positionChanged(pos); - const bool onEOS = (m_data.state == PlayerState::Playing && m_data.pendingState == PlayerState::Playing) - && ((m_data.position == 0.0f && m_data.playbackRate < 0.0f) - || (m_data.position == duration() && m_data.playbackRate > 0.0f)); + // Check if we are close enough to the end of playback that we + // are unlikely to get another position change + float timeLeft = 0.0f; + if (m_data.playbackRate < 0.0f) + timeLeft = m_data.position; + else + timeLeft = qMax(0.0f, duration() - m_data.position); + + const bool onEOS = m_data.state == PlayerState::Playing + && m_data.pendingState == PlayerState::Playing + && timeLeft < 0.1f; if (onEOS) onSlideFinished(slide); -- cgit v1.2.3