diff options
author | Mark Hung <marklh9@gmail.com> | 2019-02-27 23:20:31 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2019-03-01 00:24:05 +0100 |
commit | 71755f36394c1ffbf01af0180a05a258916dd5c9 (patch) | |
tree | 5ea1872a95852442c4e02aacff5d5ff4834c31cb /slideshow/source | |
parent | 2023b29d0f86d478748d6d0a69a38dd66c9ceb67 (diff) |
tdf#123743 deactive after the player is stopped.
The queried media duration for gstreamer isn't ready at the beginning.
Instead of deactivate the audio node immediately after querying the
duration, schedule to update the media duration and use the updated
duration to schedule deactivation.
Change-Id: I8bfa69377fbc18b21baf48bc293d2d0853e8805a
Reviewed-on: https://gerrit.libreoffice.org/68451
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'slideshow/source')
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 ); |