From 8c0414a0dec9f444a80fc30c7be3bc82188446d4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 1 Jul 2019 15:50:14 +0100 Subject: [PATCH] swaroop: write position file every 2 minutes; tweak play sensitivity on finishing a SPL; deselected playlist if stop is clicked. --- src/wx/swaroop_controls.cc | 27 +++++++++++++++++++-------- src/wx/swaroop_controls.h | 1 + 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc index 925fcb5e7..34241078b 100644 --- a/src/wx/swaroop_controls.cc +++ b/src/wx/swaroop_controls.cc @@ -158,7 +158,8 @@ SwaroopControls::check_restart () void SwaroopControls::viewer_position_changed () { - if (!_selected_playlist || !_viewer->playing() || _viewer->position().get() % DCPTime::HZ) { + /* Write position every two minutes if we're playing */ + if (!_selected_playlist || !_viewer->playing() || _viewer->position().get() % (2 * 60 * DCPTime::HZ)) { return; } @@ -186,6 +187,7 @@ SwaroopControls::started () _viewer->set_background_image (false); } +/** Called when the viewer finishes a single piece of content, or it is explicitly stopped */ void SwaroopControls::stopped () { @@ -194,6 +196,16 @@ SwaroopControls::stopped () _pause_button->Enable (false); } +void +SwaroopControls::deselect_playlist () +{ + long int const selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if (selected != -1) { + _selected_playlist = boost::none; + _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED); + } +} + void SwaroopControls::decrement_allowed_shows () { @@ -243,6 +255,7 @@ SwaroopControls::stop_clicked () } _viewer->set_background_image (true); decrement_allowed_shows (); + deselect_playlist (); } bool @@ -434,8 +447,7 @@ SwaroopControls::spl_selection_changed () if (_playlists[selected].missing()) { error_dialog (this, "This playlist cannot be loaded as some content is missing."); - _selected_playlist = boost::none; - _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED); + deselect_playlist (); return; } @@ -479,8 +491,7 @@ SwaroopControls::select_playlist (int selected, int position) if (dcp->needs_kdm()) { /* We didn't get a KDM for this */ error_dialog (this, "This playlist cannot be loaded as a KDM is missing."); - _selected_playlist = boost::none; - _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED); + deselect_playlist (); return; } } @@ -496,8 +507,7 @@ SwaroopControls::select_playlist (int selected, int position) } } else { error_dialog (this, "This playlist cannot be loaded as a KDM is missing."); - _selected_playlist = boost::none; - _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED); + deselect_playlist (); return; } } @@ -589,7 +599,8 @@ SwaroopControls::viewer_finished () _selected_playlist_position = 0; _viewer->set_background_image (true); ResetFilm (shared_ptr(new Film(optional()))); - stopped (); decrement_allowed_shows (); + _play_button->Enable (true); + _pause_button->Enable (false); } } diff --git a/src/wx/swaroop_controls.h b/src/wx/swaroop_controls.h index 10919b767..d8d39d4a0 100644 --- a/src/wx/swaroop_controls.h +++ b/src/wx/swaroop_controls.h @@ -60,6 +60,7 @@ private: bool can_do_previous (); bool can_do_next (); void decrement_allowed_shows (); + void deselect_playlist (); boost::optional get_kdm_from_url (boost::shared_ptr dcp); boost::optional get_kdm_from_directory (boost::shared_ptr dcp); -- 2.30.2