+ _overall_panel = new wxPanel (this, wxID_ANY);
+
+ _viewer.reset (new FilmViewer (_overall_panel));
+ _controls = new Controls (_overall_panel, _viewer, false);
+ _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
+ _viewer->PlaybackPermitted.connect (bind(&DOMFrame::playback_permitted, this));
+ _viewer->Started.connect (bind(&DOMFrame::playback_started, this, _1));
+ _viewer->Seeked.connect (bind(&DOMFrame::playback_seeked, this, _1));
+ _viewer->Stopped.connect (bind(&DOMFrame::playback_stopped, this, _1));
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ _viewer->PositionChanged.connect (bind(&DOMFrame::position_changed, this));
+#endif
+ _info = new PlayerInformation (_overall_panel, _viewer);
+ setup_main_sizer (Config::instance()->player_mode());
+#ifdef __WXOSX__
+ int accelerators = 4;
+#else
+ int accelerators = 3;
+#endif
+
+ wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
+ accel[0].Set(wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
+ accel[1].Set(wxACCEL_NORMAL, WXK_LEFT, ID_back_frame);
+ accel[2].Set(wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame);
+#ifdef __WXOSX__
+ accel[3].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
+#endif
+ wxAcceleratorTable accel_table (accelerators, accel);
+ SetAcceleratorTable (accel_table);
+ delete[] accel;
+
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::back_frame, this), ID_back_frame);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
+
+ reset_film ();
+
+ UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ MonitorChecker::instance()->StateChanged.connect(boost::bind(&DOMFrame::monitor_checker_state_changed, this));
+ MonitorChecker::instance()->run ();
+#endif
+ setup_screen ();
+
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ if (
+ boost::filesystem::is_regular_file(Config::path("position")) &&
+ boost::filesystem::is_regular_file(Config::path("spl.xml"))) {
+
+ shared_ptr<Film> film (new Film(boost::optional<boost::filesystem::path>()));
+ film->read_metadata (Config::path("spl.xml"));
+ reset_film (film);
+ FILE* f = fopen_boost (Config::path("position"), "r");
+ if (f) {
+ char buffer[64];
+ fscanf (f, "%63s", buffer);
+ _viewer->seek (DCPTime(atoi(buffer)), true);
+ _viewer->start ();
+ fclose (f);
+ }
+ }
+
+#endif
+ }
+
+ void position_changed ()
+ {
+ if (!_viewer->playing() || _viewer->position().get() % DCPTime::HZ) {
+ return;
+ }
+
+ FILE* f = fopen_boost (Config::path("position"), "w");
+ if (f) {
+ string const p = dcp::raw_convert<string> (_viewer->position().get());
+ fwrite (p.c_str(), p.length(), 1, f);
+ fclose (f);
+ }
+ }
+
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+ void monitor_checker_state_changed ()
+ {
+ if (!MonitorChecker::instance()->ok()) {
+ error_dialog (this, _("The required display devices are not connected correctly."));
+ _viewer->stop ();
+ }
+ }
+#endif