+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetDataSizeFromStart
+//
+// Calls either GetMovieDataSize or GetMovieDataSize64 with a value
+// of 0 for the starting value
+//---------------------------------------------------------------------------
+wxLongLong wxQTMediaBackend::GetDataSizeFromStart(TimeValue end)
+{
+#if 0 // old pre-qt4 way
+ return ::GetMovieDataSize(m_movie, 0, end)
+#else // qt4 way
+ wide llDataSize;
+ ::GetMovieDataSize64(m_movie, 0, end, &llDataSize);
+ return wxLongLong(llDataSize.hi, llDataSize.lo);
+#endif
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetDownloadProgress
+//---------------------------------------------------------------------------
+wxLongLong wxQTMediaBackend::GetDownloadProgress()
+{
+#if 0 // hackish and slow
+ Handle hMovie = NewHandle(0);
+ PutMovieIntoHandle(m_movie, hMovie);
+ long lSize = GetHandleSize(hMovie);
+ DisposeHandle(hMovie);
+
+ return lSize;
+#else
+ TimeValue tv;
+ if (::GetMaxLoadedTimeInMovie(m_movie, &tv) != noErr)
+ {
+ wxLogDebug(wxT("GetMaxLoadedTimeInMovie failed"));
+ return 0;
+ }
+
+ return wxQTMediaBackend::GetDataSizeFromStart(tv);
+#endif
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetDownloadTotal
+//---------------------------------------------------------------------------
+wxLongLong wxQTMediaBackend::GetDownloadTotal()
+{
+ return wxQTMediaBackend::GetDataSizeFromStart(
+ ::GetMovieDuration(m_movie)
+ );
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::MacVisibilityChanged
+//
+// The main problem here is that Windows quicktime, for example,
+// renders more directly to a HWND. Mac quicktime does not do this
+// and instead renders to the port of the WindowRef/WindowPtr on top
+// of everything else/all other windows.
+//
+// So, for example, if you were to have a CreateTabsControl/wxNotebook
+// and change pages, even if you called HIViewSetVisible/SetControlVisibility
+// directly the movie will still continue playing on top of everything else
+// if you went to a different tab.
+//
+// Note that another issue, and why we call MCSetControllerPort instead
+// of SetMovieGWorld directly, is that in addition to rendering on
+// top of everything else the last created controller steals mouse and
+// other input from everything else in the window, including other
+// controllers. Setting the port of it releases this behaviour.
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::MacVisibilityChanged()
+{
+ if(!m_mc || !m_ctrl->m_bLoaded)
+ return; //not initialized yet
+
+ if(m_ctrl->IsShownOnScreen())
+ {
+ //The window is being shown again, so set the GWorld of the
+ //controller back to the port of the parent WindowRef
+ WindowRef wrTLW =
+ (WindowRef) m_ctrl->MacGetTopLevelWindowRef();
+
+ ::MCSetControllerPort(m_mc, (CGrafPtr) GetWindowPort(wrTLW));
+ wxASSERT(::GetMoviesError() == noErr);
+ }
+ else
+ {
+ //We are being hidden - set the GWorld of the controller
+ //to the offscreen GWorld
+ ::MCSetControllerPort(m_mc, m_movieWorld);
+ wxASSERT(::GetMoviesError() == noErr);
+ }
+}
+