Basic and rather clumsy option to respect KDM validity windows.
[dcpomatic.git] / src / wx / film_viewer.cc
index 2d53db9ef5ec8e162f7a7b61e91979ad4e0caed3..d45da20213c3da6197a6adff0bf0df2f129ea51b 100644 (file)
@@ -91,6 +91,7 @@ FilmViewer::FilmViewer (wxWindow* p)
 #endif
 
        _panel->SetBackgroundStyle (wxBG_STYLE_PAINT);
+       _panel->SetBackgroundColour (*wxBLACK);
 
        _panel->Bind            (wxEVT_PAINT,               boost::bind (&FilmViewer::paint_panel,     this));
        _panel->Bind            (wxEVT_SIZE,                boost::bind (&FilmViewer::panel_sized,     this, _1));
@@ -405,6 +406,12 @@ FilmViewer::start ()
                return;
        }
 
+       optional<bool> v = PlaybackPermitted ();
+       if (v && !*v) {
+               /* Computer says no */
+               return;
+       }
+
        if (_audio.isStreamOpen()) {
                _audio.setStreamTime (_video_position.seconds());
                _audio.startStream ();
@@ -433,21 +440,6 @@ FilmViewer::stop ()
        return true;
 }
 
-void
-FilmViewer::go_to (DCPTime t)
-{
-       if (t < DCPTime ()) {
-               t = DCPTime ();
-       }
-
-       if (t >= _film->length ()) {
-               t = _film->length ();
-       }
-
-       seek (t, true);
-       PositionChanged ();
-}
-
 void
 FilmViewer::player_change (ChangeType type, int property, bool frequent)
 {
@@ -515,19 +507,11 @@ FilmViewer::quick_refresh ()
 }
 
 void
-FilmViewer::set_position (DCPTime p)
-{
-       _video_position = p;
-       seek (p, true);
-       PositionChanged ();
-}
-
-void
-FilmViewer::set_position (shared_ptr<Content> content, ContentTime t)
+FilmViewer::seek (shared_ptr<Content> content, ContentTime t, bool accurate)
 {
        optional<DCPTime> dt = _player->content_time_to_dcp (content, t);
        if (dt) {
-               set_position (*dt);
+               seek (*dt, accurate);
        }
 }
 
@@ -551,6 +535,14 @@ FilmViewer::seek (DCPTime t, bool accurate)
                return;
        }
 
+       if (t < DCPTime ()) {
+               t = DCPTime ();
+       }
+
+       if (t >= _film->length ()) {
+               t = _film->length ();
+       }
+
        bool const was_running = stop ();
 
        _closed_captions_dialog->clear ();
@@ -560,6 +552,8 @@ FilmViewer::seek (DCPTime t, bool accurate)
        if (was_running) {
                start ();
        }
+
+       PositionChanged ();
 }
 
 void
@@ -696,6 +690,7 @@ FilmViewer::one_video_frame () const
        return DCPTime::from_frames (1, _film->video_frame_rate());
 }
 
+/** Open a dialog box showing our film's closed captions */
 void
 FilmViewer::show_closed_captions ()
 {
@@ -703,11 +698,7 @@ FilmViewer::show_closed_captions ()
 }
 
 void
-FilmViewer::move (DCPTime by)
+FilmViewer::seek_by (DCPTime by, bool accurate)
 {
-       if (!_film) {
-               return;
-       }
-
-       go_to (_video_position + by);
+       seek (_video_position + by, accurate);
 }