Merge master.
[dcpomatic.git] / src / wx / film_viewer.cc
index f426a7c6e9f86c77764b6274586abcb2760655d1..b0bc65750f71ea8e202d973a07792a858c814c13 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -222,6 +222,11 @@ FilmViewer::slider_moved ()
 {
        if (_film && _player) {
                try {
+                       Time t = _slider->GetValue() * _film->length() / 4096;
+                       /* Ensure that we hit the end of the film at the end of the slider */
+                       if (t >= _film->length ()) {
+                               t = _film->length() - _film->video_frames_to_time (1);
+                       }
                        _player->seek (DCPTime (_film->length().get() * _slider->GetValue() / 4096), false);
                        fetch_next_frame ();
                } catch (OpenFileError& e) {
@@ -429,7 +434,7 @@ FilmViewer::player_changed (bool frequent)
        if (frequent) {
                return;
        }
-       
+
        calculate_sizes ();
        fetch_current_frame_again ();
 }