, _play_button (new wxToggleButton (this, wxID_ANY, _("Play")))
, _coalesce_player_changes (false)
, _pending_player_change (false)
- , _last_seek_accurate (true)
+ , _slider_being_moved (false)
+ , _was_running_before_slider (false)
, _audio (DCPOMATIC_RTAUDIO_API)
, _audio_channels (0)
, _audio_block_size (1024)
_left_eye->Bind (wxEVT_RADIOBUTTON, boost::bind (&FilmViewer::refresh, this));
_right_eye->Bind (wxEVT_RADIOBUTTON, boost::bind (&FilmViewer::refresh, this));
_slider->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&FilmViewer::slider_moved, this, false));
- _slider->Bind (wxEVT_SCROLL_CHANGED, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_PAGEUP, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_PAGEDOWN, boost::bind (&FilmViewer::slider_moved, this, true));
+ _slider->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind (&FilmViewer::slider_released, this));
_play_button->Bind (wxEVT_TOGGLEBUTTON, boost::bind (&FilmViewer::play_clicked, this));
_timer.Bind (wxEVT_TIMER, boost::bind (&FilmViewer::timer, this));
_rewind_button->Bind (wxEVT_LEFT_DOWN, boost::bind (&FilmViewer::rewind_clicked, this, _1));
}
}
+/** @param page true if this was a PAGEUP/PAGEDOWN event for which we won't receive a THUMBRELEASE */
void
-FilmViewer::slider_moved (bool update_slider)
+FilmViewer::slider_moved (bool page)
{
if (!_film) {
return;
}
+ if (!page && !_slider_being_moved) {
+ /* This is the first event of a drag; stop playback for the duration of the drag */
+ _was_running_before_slider = stop ();
+ _slider_being_moved = true;
+ }
DCPTime t (_slider->GetValue() * _film->length().get() / 4096);
/* Ensure that we hit the end of the film at the end of the slider */
}
seek (t, false);
update_position_label ();
- if (update_slider) {
- update_position_slider ();
+}
+
+void
+FilmViewer::slider_released ()
+{
+ if (_was_running_before_slider) {
+ /* Restart after a drag */
+ start ();
}
+ _slider_being_moved = false;
}
void
_playing = true;
_dropped = 0;
timer ();
+ _play_button->SetValue (true);
}
bool
FilmViewer::stop ()
{
if (_audio.isStreamRunning()) {
- /* stop stream and discard any remainig queued samples */
+ /* stop stream and discard any remaining queued samples */
_audio.abortStream ();
}
void
FilmViewer::refresh ()
{
- seek (_video_position, _last_seek_accurate);
+ seek (_video_position, true);
}
void
bool const was_running = stop ();
_butler->seek (t, accurate);
- _last_seek_accurate = accurate;
get ();
if (was_running) {
#endif
error_dialog (
this,
- wxString::Format (_("Could not set up audio output (%s). There will be no audio during the preview."), e.what())
+ _("Could not set up audio output. There will be no audio during the preview."), std_to_wx(e.what())
);
}
recreate_butler ();