From b2ccf5efae5261886a5aadf3f72ff095cb3b3d5b Mon Sep 17 00:00:00 2001 From: Katarina Behrens Date: Mon, 1 Apr 2019 14:45:42 +0200 Subject: tdf#100007: slider and time field update during video playback To make this happen, restart idle in timeout handler (also start it when user bonks Play button and stop it when they bonk Pause or Stop button). The idle also needs a lower prio than TaskPriority::Repaint, otherwise the higher-prio events from our idle are going to starve UI repaints in the scheduler queue Change-Id: I4c767c3533e0e2ee9015c48b17075db5e0dc7ade Reviewed-on: https://gerrit.libreoffice.org/70068 Tested-by: Jenkins Reviewed-by: Katarina Behrens --- avmedia/inc/mediacontrol.hxx | 1 + avmedia/source/framework/mediacontrol.cxx | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/avmedia/inc/mediacontrol.hxx b/avmedia/inc/mediacontrol.hxx index 99ad5ef91a01..bdf0ce300005 100644 --- a/avmedia/inc/mediacontrol.hxx +++ b/avmedia/inc/mediacontrol.hxx @@ -77,6 +77,7 @@ private: Size maMinSize; bool mbLocked; MediaControlStyle meControlStyle; + double mfTime; }; } diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index f9c645ba15c9..0988c88c0d13 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -44,7 +44,8 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl maIdle( "avmedia MediaControl Idle" ), maItem( 0, AVMediaSetMask::ALL ), mbLocked( false ), - meControlStyle( eControlStyle ) + meControlStyle( eControlStyle ), + mfTime(0.0) { mpPlayToolBox = VclPtr::Create(this, WB_3DLOOK) ; mpTimeSlider = VclPtr::Create(this, WB_HORZ | WB_DRAG | WB_3DLOOK) ; @@ -116,10 +117,10 @@ MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyl mpZoomToolBox->SetBackground(); mpZoomToolBox->SetPaintTransparent( true ); } - - maIdle.SetPriority( TaskPriority::HIGH_IDLE ); + // we want time field + progress slider to update as the media plays + // give this task a lower prio than REPAINT so that UI updates are not starved + maIdle.SetPriority( TaskPriority::POST_PAINT ); maIdle.SetInvokeHandler( LINK( this, MediaControl, implTimeoutHdl ) ); - maIdle.Start(); } void MediaControl::InitializeWidgets() @@ -245,8 +246,10 @@ void MediaControl::Resize() void MediaControl::setState( const MediaItem& rItem ) { - if( !mbLocked ) + double fTime = rItem.getTime(); + if( !mbLocked && fTime != mfTime) { + mfTime = fTime; maItem.merge( rItem ); if( rItem.getURL().isEmpty() && meControlStyle == MEDIACONTROLSTYLE_SINGLELINE ) mpPlayToolBox->Disable(); @@ -310,6 +313,12 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p, void ) else SelectPlayToolBoxItem( aExecItem, maItem, p->GetCurItemId() ); + if (aExecItem.getState() == MediaState::Play) + maIdle.Start(); + else if (aExecItem.getState() == MediaState::Pause || + aExecItem.getState() == MediaState::Stop) + maIdle.Stop(); + if( aExecItem.getMaskSet() != AVMediaSetMask::NONE ) execute( aExecItem ); } @@ -347,6 +356,7 @@ IMPL_LINK( MediaControl, implZoomSelectHdl, ListBox&, p, void ) IMPL_LINK_NOARG(MediaControl, implTimeoutHdl, Timer *, void) { update(); + maIdle.Start(); } } // namespace avmedia -- cgit