- /* We could do this with a seek and a fetch_next_frame, but this is
- a shortcut to make it quicker.
- */
-
- _got_frame = false;
- if (!_player->repeat_last_video ()) {
- fetch_next_frame ();
+ list<shared_ptr<PlayerVideo> > pvf = _player->get_video (p, accurate);
+ if (!pvf.empty ()) {
+ try {
+ _frame = pvf.front()->image (PIX_FMT_RGB24, true);
+ _frame = _frame->scale (_frame->size(), Scaler::from_id ("fastbilinear"), PIX_FMT_RGB24, false);
+ _position = pvf.front()->time ();
+ _inter_position = pvf.front()->inter_position ();
+ _inter_size = pvf.front()->inter_size ();
+ } catch (dcp::DCPReadError& e) {
+ /* This can happen on the following sequence of events:
+ * - load encrypted DCP
+ * - add KDM
+ * - DCP is examined again, which sets its "playable" flag to 1
+ * - as a side effect of the exam, the viewer is updated using the old pieces
+ * - the DCPDecoder in the old piece gives us an encrypted frame
+ * - then, the pieces are re-made (but too late).
+ *
+ * I hope there's a better way to handle this ...
+ */
+ _frame.reset ();
+ _position = p;
+ }
+ } else {
+ _frame.reset ();
+ _position = p;