+ playRate = ::GetMoviePreferredRate(m_movie);
+ wxASSERT(::GetMoviesError() == noErr);
+
+ //
+ // Note that the callback here is optional,
+ // but without it PrePrerollMovie can be buggy
+ // (see Apple ml). Also, some may wonder
+ // why we need this at all - this is because
+ // Apple docs say QuickTime streamed movies
+ // require it if you don't use a Movie Controller,
+ // which we don't by default.
+ //
+ m_preprerollupp =
+ NewMoviePrePrerollCompleteUPP( wxQTMediaBackend::PPRMProc );
+ ::PrePrerollMovie( m_movie, timeNow, playRate,
+ m_preprerollupp, (void*)this);
+
+ return true;
+ }
+
+ return false;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::DoNewMovieController
+//
+// Attaches movie to moviecontroller or creates moviecontroller
+// if not created yet
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::DoNewMovieController()
+{
+ 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 =
+ NewMCActionFilterWithRefConUPP( 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);
+ }