diff options
Diffstat (limited to 'slideshow')
4 files changed, 25 insertions, 3 deletions
diff --git a/slideshow/source/engine/animationnodes/animationaudionode.cxx b/slideshow/source/engine/animationnodes/animationaudionode.cxx index b024de24de53..9e3f6bc25271 100644 --- a/slideshow/source/engine/animationnodes/animationaudionode.cxx +++ b/slideshow/source/engine/animationnodes/animationaudionode.cxx @@ -76,12 +76,14 @@ void AnimationAudioNode::activate_st() } else { - // no node duration. Take inherent media time, then + // no node duration. Take inherent media time. We have to recheck + // if the player is playing in case the duration isn't accurate + // or the progress fall behind. auto self(getSelf()); scheduleDeactivationEvent( - makeDelay( [self] () { self->deactivate(); }, + makeDelay( [this] () { this->checkPlayingStatus(); }, mpPlayer->getDuration(), - "AnimationAudioNode::deactivate with delay") ); + "AnimationAudioNode::check if sitll playing with delay") ); } } else @@ -182,6 +184,19 @@ bool AnimationAudioNode::handleAnimationEvent( return true; } +void AnimationAudioNode::checkPlayingStatus() +{ + auto self(getSelf()); + double nDuration = mpPlayer->getDuration(); + if (!mpPlayer->isPlaying() || nDuration < 0.0) + nDuration = 0.0; + + scheduleDeactivationEvent( + makeDelay( [self] () { self->deactivate(); }, + nDuration, + "AnimationAudioNode::deactivate with delay") ); +} + } // namespace internal } // namespace presentation diff --git a/slideshow/source/engine/animationnodes/animationaudionode.hxx b/slideshow/source/engine/animationnodes/animationaudionode.hxx index 6efd40fdbd20..30de41cfb44e 100644 --- a/slideshow/source/engine/animationnodes/animationaudionode.hxx +++ b/slideshow/source/engine/animationnodes/animationaudionode.hxx @@ -59,6 +59,7 @@ private: void createPlayer() const; void resetPlayer() const; + void checkPlayingStatus(); }; } // namespace internal diff --git a/slideshow/source/engine/soundplayer.cxx b/slideshow/source/engine/soundplayer.cxx index 65b578304d62..18a1948089f9 100644 --- a/slideshow/source/engine/soundplayer.cxx +++ b/slideshow/source/engine/soundplayer.cxx @@ -170,6 +170,11 @@ namespace slideshow if( mxPlayer.is() ) mxPlayer->setPlaybackLoop( bLoop ); } + + bool SoundPlayer::isPlaying() const + { + return mxPlayer->isPlaying(); + } } } diff --git a/slideshow/source/inc/soundplayer.hxx b/slideshow/source/inc/soundplayer.hxx index ea496d88b8cc..92ac94b851fb 100644 --- a/slideshow/source/inc/soundplayer.hxx +++ b/slideshow/source/inc/soundplayer.hxx @@ -83,6 +83,7 @@ namespace slideshow bool startPlayback(); bool stopPlayback(); + bool isPlaying() const; void setPlaybackLoop( bool bLoop ); |