swaroop: write position file every 2 minutes; tweak play sensitivity v2.15.9
authorCarl Hetherington <cth@carlh.net>
Mon, 1 Jul 2019 14:50:14 +0000 (15:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 1 Jul 2019 14:50:14 +0000 (15:50 +0100)
on finishing a SPL; deselected playlist if stop is clicked.

src/wx/swaroop_controls.cc
src/wx/swaroop_controls.h

index 925fcb5e720961c7121ff604127399726b504470..34241078b0dfc1c54af93c38a59f63a8a70b2676 100644 (file)
@@ -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<Film>(new Film(optional<boost::filesystem::path>())));
-               stopped ();
                decrement_allowed_shows ();
+               _play_button->Enable (true);
+               _pause_button->Enable (false);
        }
 }
index 10919b7678e8f146eb37a136542dde90bac07354..d8d39d4a0153d4292f1e2c4838e99936992116de 100644 (file)
@@ -60,6 +60,7 @@ private:
        bool can_do_previous ();
        bool can_do_next ();
        void decrement_allowed_shows ();
+       void deselect_playlist ();
 
        boost::optional<dcp::EncryptedKDM> get_kdm_from_url (boost::shared_ptr<DCPContent> dcp);
        boost::optional<dcp::EncryptedKDM> get_kdm_from_directory (boost::shared_ptr<DCPContent> dcp);