summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-12-13 01:06:46 +0000
committerCarl Hetherington <cth@carlh.net>2018-12-13 01:06:46 +0000
commite81d3bb9857d9de7ec9468a3efcb812042f5cef9 (patch)
tree64af123498db3929e1e401a18413df717951f03c /src
parent5ab24a511575f1887331f24fd0911c614df3c3c0 (diff)
swaroop: partial rework of SPL management.
Diffstat (limited to 'src')
-rw-r--r--src/wx/film_viewer.cc5
-rw-r--r--src/wx/film_viewer.h2
-rw-r--r--src/wx/swaroop_controls.cc92
-rw-r--r--src/wx/swaroop_controls.h6
4 files changed, 46 insertions, 59 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 0f3869761..90f8c9fd2 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -121,6 +121,9 @@ FilmViewer::set_film (shared_ptr<Film> film)
}
_film = film;
+ _video_position = DCPTime ();
+ _player_video.first.reset ();
+ _player_video.second = DCPTime ();
_frame.reset ();
_closed_captions_dialog->clear ();
@@ -295,6 +298,8 @@ FilmViewer::timer ()
if (next >= _film->length()) {
stop ();
+ Finished ();
+ return;
}
_timer.Start (max ((next.seconds() - time().seconds()) * 1000, 1.0), wxTIMER_ONE_SHOT);
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index 8b45048a7..73c923c26 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -93,6 +93,8 @@ public:
boost::signals2::signal<void (DCPTime)> Started;
boost::signals2::signal<void (DCPTime)> Stopped;
boost::signals2::signal<void (DCPTime)> Seeked;
+ /** While playing back we reached the end of the film (emitted from GUI thread) */
+ boost::signals2::signal<void ()> Finished;
boost::signals2::signal<bool ()> PlaybackPermitted;
diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc
index 99a19f5de..909cb0dc4 100644
--- a/src/wx/swaroop_controls.cc
+++ b/src/wx/swaroop_controls.cc
@@ -98,7 +98,7 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
_stop_button->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::stop_clicked, this));
_spl_view->Bind (wxEVT_LIST_ITEM_SELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
_spl_view->Bind (wxEVT_LIST_ITEM_DESELECTED, boost::bind(&SwaroopControls::spl_selection_changed, this));
- _viewer->ImageChanged.connect (boost::bind(&SwaroopControls::image_changed, this, _1));
+ _viewer->Finished.connect (boost::bind(&SwaroopControls::viewer_finished, this));
_refresh_spl_view->Bind (wxEVT_BUTTON, boost::bind(&SwaroopControls::update_playlist_directory, this));
_refresh_content_view->Bind (wxEVT_BUTTON, boost::bind(&ContentView::update, _content_view));
@@ -135,9 +135,8 @@ SwaroopControls::setup_sensitivity ()
bool const active_job = _active_job && *_active_job != "examine_content";
bool const c = _film && !_film->content().empty() && !active_job;
_play_button->Enable (c && !_viewer->playing());
- _pause_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && _viewer->playing());
- _stop_button->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT));
- _slider->Enable (c && (!_current_kind || _current_kind != dcp::ADVERTISEMENT) && !_current_disable_timeline);
+ _pause_button->Enable (_viewer->playing());
+ _slider->Enable (!_current_disable_timeline);
_spl_view->Enable (!_viewer->playing());
}
@@ -168,45 +167,6 @@ SwaroopControls::log (wxString s)
}
void
-SwaroopControls::image_changed (boost::weak_ptr<PlayerVideo> weak_pv)
-{
- shared_ptr<PlayerVideo> pv = weak_pv.lock ();
- if (!pv) {
- return;
- }
-
- shared_ptr<Content> c = pv->content().lock();
- if (!c) {
- return;
- }
-
- if (c == _current_content.lock()) {
- return;
- }
-
- _current_content = c;
-
- if (_selected_playlist) {
- BOOST_FOREACH (SPLEntry i, _playlists[*_selected_playlist].get()) {
- if (i.content == c) {
- _current_disable_timeline = i.disable_timeline;
- setup_sensitivity ();
- }
- }
- }
-
- shared_ptr<DCPContent> dc = dynamic_pointer_cast<DCPContent> (c);
- if (!dc) {
- return;
- }
-
- if (!_current_kind || *_current_kind != dc->content_kind()) {
- _current_kind = dc->content_kind ();
- setup_sensitivity ();
- }
-}
-
-void
SwaroopControls::add_playlist_to_list (SPL spl)
{
int const N = _spl_view->GetItemCount();
@@ -266,21 +226,12 @@ SwaroopControls::spl_selection_changed ()
return;
}
- wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic"), _("Loading playlist"));
-
- shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
- BOOST_FOREACH (SPLEntry i, _playlists[selected].get()) {
- film->add_content (i.content);
- if (!progress->Pulse()) {
- /* user pressed cancel */
- _selected_playlist = boost::none;
- _spl_view->SetItemState (selected, 0, wxLIST_STATE_SELECTED);
- progress->Destroy ();
- return;
- }
+ if (_playlists[selected].get().empty()) {
+ error_dialog (this, "This playlist is empty.");
+ return;
}
- progress->Destroy ();
+
_current_spl_view->DeleteAllItems ();
int N = 0;
@@ -294,6 +245,16 @@ SwaroopControls::spl_selection_changed ()
}
_selected_playlist = selected;
+ _selected_playlist_position = 0;
+ reset_film ();
+}
+
+void
+SwaroopControls::reset_film ()
+{
+ DCPOMATIC_ASSERT (_selected_playlist);
+ shared_ptr<Film> film (new Film(optional<boost::filesystem::path>()));
+ film->add_content (_playlists[*_selected_playlist].get()[_selected_playlist_position].content);
ResetFilm (film);
}
@@ -315,3 +276,22 @@ SwaroopControls::set_film (shared_ptr<Film> film)
Controls::set_film (film);
setup_sensitivity ();
}
+
+void
+SwaroopControls::viewer_finished ()
+{
+ if (!_selected_playlist) {
+ return;
+ }
+
+ ++_selected_playlist_position;
+
+ SPL const & playlist = _playlists[*_selected_playlist];
+
+ if (_selected_playlist_position < int(playlist.get().size())) {
+ _current_disable_timeline = playlist.get()[_selected_playlist_position].disable_timeline;
+ setup_sensitivity ();
+ reset_film ();
+ _viewer->start ();
+ }
+}
diff --git a/src/wx/swaroop_controls.h b/src/wx/swaroop_controls.h
index 54f77de17..7012bcb47 100644
--- a/src/wx/swaroop_controls.h
+++ b/src/wx/swaroop_controls.h
@@ -45,8 +45,9 @@ private:
void started ();
void stopped ();
void setup_sensitivity ();
- void image_changed (boost::weak_ptr<PlayerVideo> weak_pv);
void config_changed (int);
+ void viewer_finished ();
+ void reset_film ();
wxButton* _play_button;
wxButton* _pause_button;
@@ -59,10 +60,9 @@ private:
wxListCtrl* _current_spl_view;
wxTextCtrl* _log;
- boost::weak_ptr<Content> _current_content;
- boost::optional<dcp::ContentKind> _current_kind;
bool _current_disable_timeline;
std::vector<SPL> _playlists;
boost::optional<int> _selected_playlist;
+ int _selected_playlist_position;
};