+ 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.
+ //
+ ::PrePrerollMovie(m_movie, timeNow, playRate,
+ wxQTMediaBackend::PPRMProc,
+ (void*)this);
+#endif
+ return true;
+ }
+ else
+ return false;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::DoCreateMovieControl
+//
+// Calls CreateMovieControl and performs setup related to it
+//
+// Note that we always hide the controller initially becuase when loading
+// from a url it displays about a 40x40 box with the word loading... in it,
+// but the box is outside the range of the control, which is bad (0,0
+// i believe), so we need to wait until finishload to actually display
+// the movie controller in this instance
+//---------------------------------------------------------------------------
+#if wxUSE_CREATEMOVIECONTROL
+void wxQTMediaBackend::DoCreateMovieControl()
+{
+ //
+ //Native CreateMovieControl QT control (Thanks to Kevin Olliver's
+ //wxQTMovie for some of this).
+ //
+ Rect bounds = wxMacGetBoundsForControl(m_ctrl,
+ m_ctrl->GetPosition(),
+ m_ctrl->GetSize());
+
+ //Dispose of old control for new one
+ if (m_ctrl->m_peer && m_ctrl->m_peer->Ok() )
+ m_ctrl->m_peer->Dispose();
+
+ //Options-
+ //kMovieControlOptionXXX
+ //HideController - hide the movie controller
+ //LocateTopLeft - movie is pinned to top left rather than centered in the control
+ //EnableEditing - Allows programmatic editing and dragn'drop
+ //HandleEditingHI- Installs event stuff for edit menu - forces EnableEditing also
+ //SetKeysEnabled - Allows keyboard input
+ //ManuallyIdled - app handles movie idling rather than internal timer event loop
+ ::CreateMovieControl(
+ (WindowRef)
+ m_ctrl->MacGetTopLevelWindowRef(), //parent
+ &bounds, //control bounds
+ m_movie, //movie handle
+ kMovieControlOptionHideController
+ | kMovieControlOptionLocateTopLeft
+ | kMovieControlOptionSetKeysEnabled
+ // | kMovieControlOptionManuallyIdled
+ , //flags
+ m_ctrl->m_peer->GetControlRefAddr() );
+
+ ::EmbedControl(m_ctrl->m_peer->GetControlRef(),
+ (ControlRef)m_ctrl->GetParent()->GetHandle());
+
+ //
+ // Setup MovieController for the new movie
+ //
+ long dataSize;
+
+ //Get movie controller from our control
+ ::GetControlData( m_ctrl->m_peer->GetControlRef(), 0,
+ kMovieControlDataMovieController,
+ sizeof(MovieController), (Ptr)&m_mc, &dataSize );
+
+ // Setup a callback so we can tell when the user presses
+ // play on the player controls
+ ::MCSetActionFilterWithRefCon(m_mc,
+ wxQTMediaBackend::MCFilterProc, (long)this);
+}
+#endif
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::DoNewMovieController
+//
+// Attaches movie to moviecontroller or creates moviecontroller
+// if not created yet
+//---------------------------------------------------------------------------
+#if !wxUSE_CREATEMOVIECONTROL
+void wxQTMediaBackend::DoNewMovieController()
+{
+ if(!m_mc)
+ {
+ // Get top level window ref for some mac functions
+ WindowRef wrTLW = (WindowRef) m_ctrl->MacGetTopLevelWindowRef();
+
+ // MovieController not setup 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 |
+ //mcWithFrame |
+ mcNotVisible);
+ 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
+ ::MCSetActionFilterWithRefCon(m_mc,
+ wxQTMediaBackend::MCFilterProc, (long)this);
+ wxASSERT(::GetMoviesError() == noErr);
+
+ //Part of a suggestion from Greg Hazel to repaint
+ //movie when idle
+ m_ctrl->PushEventHandler(new wxQTMediaEvtHandler(this));
+
+ // Event types to catch from the TLW
+ // for the moviecontroller
+ EventTypeSpec theEventTypes[] = {
+ { kEventClassMouse, kEventMouseDown },
+ { kEventClassMouse, kEventMouseUp },
+ { kEventClassKeyboard, kEventRawKeyDown },
+ { kEventClassKeyboard, kEventRawKeyRepeat },
+ { kEventClassKeyboard, kEventRawKeyUp },
+ { kEventClassWindow, kEventWindowUpdate },
+ { kEventClassWindow, kEventWindowActivated },
+ { kEventClassWindow, kEventWindowDeactivated }
+ };
+
+ // 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...
+ InstallWindowEventHandler( wrTLW,
+ GetwxQTMediaWindowEventHandlerUPP(),
+ GetEventTypeCount( theEventTypes ), theEventTypes,
+ m_mc, (&(EventHandlerRef&)m_pEventHandlerRef) );
+ }
+ 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);
+ }