Fix video timing and stop the viewer at the end of the film.
authorCarl Hetherington <cth@carlh.net>
Tue, 18 Apr 2017 09:57:19 +0000 (10:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 19 Apr 2017 22:04:32 +0000 (23:04 +0100)
src/wx/film_viewer.cc

index 2aef50c..56f9c15 100644 (file)
@@ -306,11 +306,15 @@ FilmViewer::timer ()
        }
 
        if (_audio.isStreamRunning ()) {
-               DCPTime const now = time().ceil (_film->video_frame_rate ());
                get ();
                update_position_label ();
                update_position_slider ();
-               DCPTime const next = now + DCPTime::from_frames (1, _film->video_frame_rate ());
+               DCPTime const next = _video_position + DCPTime::from_frames (1, _film->video_frame_rate ());
+
+               if (next >= _film->length()) {
+                       stop ();
+               }
+
                _timer.Start (max ((next.seconds() - time().seconds()) * 1000, 0.0), wxTIMER_ONE_SHOT);
        }