+ if (!_playlists[selected].have_allowed_shows()) {
+ error_dialog (this, "There are no more allowed shows of this playlist.");
+ return;
+ }
+
+ select_playlist (selected, 0);
+}
+
+void
+SwaroopControls::select_playlist (int selected, int position)
+{
+ log (wxString::Format("load-playlist %s", std_to_wx(_playlists[selected].name()).data()));
+
+ wxProgressDialog dialog (_("DCP-o-matic"), "Loading playlist and KDMs");
+
+ BOOST_FOREACH (SPLEntry const & i, _playlists[selected].get()) {
+ dialog.Pulse ();
+ shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content);
+ if (dcp && dcp->needs_kdm()) {
+ optional<dcp::EncryptedKDM> kdm;
+ kdm = get_kdm_from_url (dcp);
+ if (!kdm) {
+ kdm = get_kdm_from_directory (dcp);
+ }
+ if (kdm) {
+ try {
+ dcp->add_kdm (*kdm);
+ dcp->examine (_film, shared_ptr<Job>());
+ } catch (KDMError& e) {
+ error_dialog (this, "Could not load KDM.");
+ }
+ }
+ if (dcp->needs_kdm()) {
+ /* We didn't get a KDM for this */
+ error_dialog (this, "This playlist cannot be loaded as a KDM is missing or incorrect.");
+ deselect_playlist ();
+ return;
+ }
+ }
+ shared_ptr<FFmpegContent> ffmpeg = dynamic_pointer_cast<FFmpegContent> (i.content);
+ if (ffmpeg && ffmpeg->encrypted()) {
+ optional<EncryptedECinemaKDM> kdm = get_kdm_from_directory (ffmpeg);
+ if (kdm) {
+ try {
+ ffmpeg->add_kdm (*kdm);
+ ffmpeg->examine (_film, shared_ptr<Job>());
+ } catch (KDMError& e) {
+ error_dialog (this, "This playlist cannot be loaded as a KDM is missing or incorrect.");
+ deselect_playlist ();
+ return;
+ }
+ } else {
+ error_dialog (this, "This playlist cannot be loaded as a KDM is missing or incorrect.");
+ deselect_playlist ();
+ return;
+ }
+ }
+ }