+ if (!m_mc)
+ {
+ // Get top level window ref for some mac functions
+ WindowRef wrTLW = (WindowRef) m_ctrl->MacGetTopLevelWindowRef();
+
+ // MovieController not set up yet, so we need to create a new one.
+ // You have to pass a valid movie to NewMovieController, evidently
+ ::SetMovieGWorld(m_movie,
+ (CGrafPtr) GetWindowPort(wrTLW),
+ NULL);
+ wxASSERT(::GetMoviesError() == noErr);
+
+ Rect bounds = wxMacGetBoundsForControl(
+ m_ctrl,
+ m_ctrl->GetPosition(),
+ m_ctrl->GetSize());
+
+ m_mc = ::NewMovieController(
+ m_movie, &bounds,
+ mcTopLeftMovie | mcNotVisible /* | mcWithFrame */ );
+ wxASSERT(::GetMoviesError() == noErr);
+
+ ::MCDoAction(m_mc, 32, (void*)true); // mcActionSetKeysEnabled
+ wxASSERT(::GetMoviesError() == noErr);
+
+ // Setup a callback so we can tell when the user presses
+ // play on the player controls
+ m_mcactionupp = wxQTMediaBackend::MCFilterProc;
+ ::MCSetActionFilterWithRefCon( m_mc, m_mcactionupp, (long)this );
+ wxASSERT(::GetMoviesError() == noErr);
+
+ // Part of a suggestion from Greg Hazel to repaint movie when idle
+ m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this));
+
+ // Create offscreen GWorld for where to "show" when window is hidden
+ Rect worldRect;
+ worldRect.left = worldRect.top = 0;
+ worldRect.right = worldRect.bottom = 1;
+ ::NewGWorld(&m_movieWorld, 0, &worldRect, NULL, NULL, 0);
+
+ // Catch window messages:
+ // if we do not do this and if the user clicks the play
+ // button on the controller, for instance, nothing will happen...
+ EventTypeSpec theWindowEventTypes[] =
+ {
+ { kEventClassMouse, kEventMouseDown },
+ { kEventClassMouse, kEventMouseUp },
+ { kEventClassMouse, kEventMouseDragged },
+ { kEventClassKeyboard, kEventRawKeyDown },
+ { kEventClassKeyboard, kEventRawKeyRepeat },
+ { kEventClassKeyboard, kEventRawKeyUp },
+ { kEventClassWindow, kEventWindowUpdate },
+ { kEventClassWindow, kEventWindowActivated },
+ { kEventClassWindow, kEventWindowDeactivated }
+ };
+ m_windowUPP =
+ NewEventHandlerUPP( wxQTMediaBackend::WindowEventHandler );
+ InstallWindowEventHandler(
+ wrTLW,
+ m_windowUPP,
+ GetEventTypeCount( theWindowEventTypes ), theWindowEventTypes,
+ this,
+ &m_windowEventHandler );
+ }
+ else
+ {
+ // MovieController already created:
+ // Just change the movie in it and we're good to go
+ Point thePoint;
+ thePoint.h = thePoint.v = 0;
+ ::MCSetMovie(m_mc, m_movie,
+ (WindowRef)m_ctrl->MacGetTopLevelWindowRef(),
+ thePoint);
+ wxASSERT(::GetMoviesError() == noErr);
+ }
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::FinishLoad
+//
+// Performs operations after a movie ready to play/loaded.
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::FinishLoad()
+{
+ // get the real size of the movie
+ DoLoadBestSize();
+
+ // show the player controls if the user wants to
+ if (m_interfaceflags)
+ DoSetControllerVisible(m_interfaceflags);
+
+ // we want millisecond precision
+ ::SetMovieTimeScale(m_movie, 1000);
+ wxASSERT(::GetMoviesError() == noErr);
+
+ // start movie progress timer
+ m_timer = new wxQTMediaPlayTimer(this);