summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/swaroop_controls.cc47
-rw-r--r--src/wx/swaroop_controls.h2
2 files changed, 48 insertions, 1 deletions
diff --git a/src/wx/swaroop_controls.cc b/src/wx/swaroop_controls.cc
index 6a40e1fc0..6e3d052eb 100644
--- a/src/wx/swaroop_controls.cc
+++ b/src/wx/swaroop_controls.cc
@@ -26,6 +26,8 @@
#include "static_text.h"
#include "lib/player_video.h"
#include "lib/dcp_content.h"
+#include "lib/cross.h"
+#include <dcp/raw_convert.h>
#include <wx/listctrl.h>
#include <wx/progdlg.h>
@@ -106,6 +108,7 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
_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->Finished.connect (boost::bind(&SwaroopControls::viewer_finished, this));
+ _viewer->PositionChanged.connect (boost::bind(&SwaroopControls::viewer_position_changed, 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));
@@ -114,6 +117,49 @@ SwaroopControls::SwaroopControls (wxWindow* parent, shared_ptr<FilmViewer> viewe
}
void
+SwaroopControls::check_restart ()
+{
+ FILE* f = fopen_boost (Config::path("position"), "r");
+ if (!f) {
+ return;
+ }
+
+ char id[64];
+ int index;
+ int64_t time;
+ fscanf (f, "%63s %d %ld", id, &index, &time);
+
+ for (size_t i = 0; i < _playlists.size(); ++i) {
+ if (_playlists[i].id() == id) {
+ _selected_playlist = i;
+ _selected_playlist_position = index;
+ update_current_content ();
+ _viewer->seek (DCPTime(time), false);
+ }
+ }
+
+ fclose (f);
+}
+
+void
+SwaroopControls::viewer_position_changed ()
+{
+ if (!_selected_playlist || !_viewer->playing() || _viewer->position().get() % DCPTime::HZ) {
+ return;
+ }
+
+ FILE* f = fopen_boost (Config::path("position"), "w");
+ if (f) {
+ string const p = _playlists[*_selected_playlist].id()
+ + " " + dcp::raw_convert<string>(_selected_playlist_position)
+ + " " + dcp::raw_convert<string>(_viewer->position().get());
+
+ fwrite (p.c_str(), p.length(), 1, f);
+ fclose (f);
+ }
+}
+
+void
SwaroopControls::started ()
{
Controls::started ();
@@ -274,7 +320,6 @@ SwaroopControls::spl_selection_changed ()
return;
}
-
_current_spl_view->DeleteAllItems ();
int N = 0;
diff --git a/src/wx/swaroop_controls.h b/src/wx/swaroop_controls.h
index 2d0d14a67..f09344d1a 100644
--- a/src/wx/swaroop_controls.h
+++ b/src/wx/swaroop_controls.h
@@ -27,6 +27,7 @@ public:
void log (wxString s);
void set_film (boost::shared_ptr<Film> film);
+ void check_restart ();
/** This is so that we can tell our parent player to reset the film
when we have created one from a SPL. We could call a method
@@ -49,6 +50,7 @@ private:
void setup_sensitivity ();
void config_changed (int);
void viewer_finished ();
+ void viewer_position_changed ();
void reset_film ();
void update_current_content ();
bool can_do_previous ();