+ result = (err == noErr);
+ if (result)
+ {
+#if wxUSE_CREATEMOVIECONTROL
+ // Movie control does its own "(pre)prerolling"
+ // but we still need to buffer the movie for the URL
+ DoCreateMovieControl();
+
+ // Setup timer to catch load event
+ m_timer = new wxQTMediaLoadTimer(m_movie, this);
+ m_timer->Start(MOVIE_DELAY);
+#else
+ // Movie controller resets prerolling, so we must create first
+ DoNewMovieController();
+
+ long timeNow;
+ Fixed playRate;
+
+ timeNow = ::GetMovieTime(m_movie, NULL);
+ wxASSERT(::GetMoviesError() == noErr);
+
+ 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);
+#endif
+ }
+
+ return result;
+}
+
+//---------------------------------------------------------------------------
+// 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// flags
+ // | kMovieControlOptionManuallyIdled
+ | kMovieControlOptionLocateTopLeft
+ | kMovieControlOptionSetKeysEnabled,
+ m_ctrl->m_peer->GetControlRefAddr() );
+
+ ::EmbedControl(
+ m_ctrl->m_peer->GetControlRef(),
+ (ControlRef)m_ctrl->GetParent()->GetHandle());
+
+ // set up 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,
+ (MCActionFilterWithRefConUPP)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 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);