diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-04-01 14:45:42 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-04-02 12:05:17 +0200 |
commit | b2ccf5efae5261886a5aadf3f72ff095cb3b3d5b (patch) | |
tree | 9d1f9fe3341f9da866114afc7bafbe5c5e9c98e1 /avmedia/source/framework | |
parent | bac831c8f5fb5c50ddddfb2458498fb9564c127a (diff) |
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 <Katarina.Behrens@cib.de>
Diffstat (limited to 'avmedia/source/framework')
-rw-r--r-- | avmedia/source/framework/mediacontrol.cxx | 20 |
1 files changed, 15 insertions, 5 deletions
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<ToolBox>::Create(this, WB_3DLOOK) ; mpTimeSlider = VclPtr<Slider>::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 |