]> git.saurik.com Git - wxWidgets.git/commitdiff
prelimanary wxMediaCtrl cocoa support
authorRyan Norton <wxprojects@comcast.net>
Thu, 3 Feb 2005 23:12:46 +0000 (23:12 +0000)
committerRyan Norton <wxprojects@comcast.net>
Thu, 3 Feb 2005 23:12:46 +0000 (23:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

Makefile.in
build/bakefiles/files.bkl
configure
configure.in
include/wx/mediactrl.h
src/cocoa/mediactrl.mm [new file with mode: 0644]

index 463b5a036dff8bc74773b5443c79f792ce56b902..a3c2054d5e1f49a01a708ec5f6bc517279e8232c 100644 (file)
@@ -75,7 +75,7 @@ WXREGEX_OBJECTS =  \
        wxregex_regexec.o \
        wxregex_regerror.o \
        wxregex_regfree.o
-WXZLIB_CFLAGS =      $(____SHARED) $(CPPFLAGS) $(CFLAGS)
+WXZLIB_CFLAGS =       $(____SHARED) $(CPPFLAGS) $(CFLAGS)
 WXZLIB_OBJECTS =  \
        wxzlib_adler32.o \
        wxzlib_compress.o \
@@ -89,7 +89,7 @@ WXZLIB_OBJECTS =  \
        wxzlib_infback.o \
        wxzlib_inftrees.o \
        wxzlib_inffast.o
-WXPNG_CFLAGS =     $(__INC_ZLIB_p)  $(____SHARED) $(CPPFLAGS) $(CFLAGS)
+WXPNG_CFLAGS =      $(__INC_ZLIB_p)  $(____SHARED) $(CPPFLAGS) $(CFLAGS)
 WXPNG_OBJECTS =  \
        wxpng_png.o \
        wxpng_pngerror.o \
@@ -108,7 +108,7 @@ WXPNG_OBJECTS =  \
        wxpng_pngwrite.o \
        wxpng_pngwtran.o \
        wxpng_pngwutil.o
-WXJPEG_CFLAGS =      $(____SHARED) $(CPPFLAGS) $(CFLAGS)
+WXJPEG_CFLAGS =       $(____SHARED) $(CPPFLAGS) $(CFLAGS)
 WXJPEG_OBJECTS =  \
        wxjpeg_jcomapi.o \
        wxjpeg_jutils.o \
@@ -193,7 +193,7 @@ WXTIFF_OBJECTS =  \
        wxtiff_tif_warning.o \
        wxtiff_tif_write.o \
        wxtiff_tif_zip.o
-WXODBC_CFLAGS =      $(____SHARED) $(CPPFLAGS) $(CFLAGS)
+WXODBC_CFLAGS =       $(____SHARED) $(CPPFLAGS) $(CFLAGS)
 WXODBC_OBJECTS =  \
        wxodbc_catalog.o \
        wxodbc_connect.o \
@@ -210,7 +210,7 @@ WXODBC_OBJECTS =  \
        wxodbc_misc.o \
        wxodbc_prepare.o \
        wxodbc_result.o
-WXEXPAT_CFLAGS =     -I./src/expat  $(____SHARED) $(CPPFLAGS) $(CFLAGS)
+WXEXPAT_CFLAGS =      -I./src/expat  $(____SHARED) $(CPPFLAGS) $(CFLAGS)
 WXEXPAT_OBJECTS =  \
        wxexpat_xmlparse.o \
        wxexpat_xmlrole.o \
@@ -3874,7 +3874,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS =  \
 @COND_WXUNIV_1@__ADVANCED_SRC_OBJECTS = $(COND_WXUNIV_1___ADVANCED_SRC_OBJECTS)
 @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS \
 @COND_TOOLKIT_MSW@     = monodll_datectrl.o
-@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS = 
+@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS = monodll_mediactrl.o
 @COND_TOOLKIT_GTK@__MEDIA_PLATFORM_SRC_OBJECTS =  
 @COND_TOOLKIT_MAC@__MEDIA_PLATFORM_SRC_OBJECTS = monodll_mediactrl.o
 @COND_TOOLKIT_MOTIF@__MEDIA_PLATFORM_SRC_OBJECTS = 
@@ -5317,7 +5317,7 @@ COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_1 =  \
 @COND_WXUNIV_1@__ADVANCED_SRC_OBJECTS_1 = $(COND_WXUNIV_1___ADVANCED_SRC_OBJECTS_1)
 @COND_TOOLKIT_MSW@__ADVANCED_PLATFORM_NATIVE_SRC_OBJECTS_1 \
 @COND_TOOLKIT_MSW@     = monolib_datectrl.o
-@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_1 = 
+@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_1 = monolib_mediactrl.o
 @COND_TOOLKIT_GTK@__MEDIA_PLATFORM_SRC_OBJECTS_1 =  
 @COND_TOOLKIT_MAC@__MEDIA_PLATFORM_SRC_OBJECTS_1 = monolib_mediactrl.o
 @COND_TOOLKIT_MOTIF@__MEDIA_PLATFORM_SRC_OBJECTS_1 = 
@@ -8239,7 +8239,7 @@ COND_USE_SOSYMLINKS_1___mediadll___so_symlinks_inst_cmd = rm -f \
        $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf2) \
        $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX)
 @COND_USE_SOSYMLINKS_1@__mediadll___so_symlinks_inst_cmd = $(COND_USE_SOSYMLINKS_1___mediadll___so_symlinks_inst_cmd)
-@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_2 = 
+@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_2 = mediadll_mediactrl.o
 @COND_TOOLKIT_GTK@__MEDIA_PLATFORM_SRC_OBJECTS_2 =  
 @COND_TOOLKIT_MAC@__MEDIA_PLATFORM_SRC_OBJECTS_2 = mediadll_mediactrl.o
 @COND_TOOLKIT_MOTIF@__MEDIA_PLATFORM_SRC_OBJECTS_2 = 
@@ -8255,7 +8255,7 @@ COND_MONOLITHIC_0_SHARED_0_USE_GUI_1___medialib___depname = \
 @COND_GCC_PCH_1@__medialib_PCH_INC = -I.pch/wxprec_medialib
 @COND_GCC_PCH_1@___pch_wxprec_medialib_wx_wxprec_h_gch___depname \
 @COND_GCC_PCH_1@       = .pch/wxprec_medialib/wx/wxprec.h.gch
-@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_3 = 
+@COND_TOOLKIT_COCOA@__MEDIA_PLATFORM_SRC_OBJECTS_3 = medialib_mediactrl.o
 @COND_TOOLKIT_GTK@__MEDIA_PLATFORM_SRC_OBJECTS_3 =  
 @COND_TOOLKIT_MAC@__MEDIA_PLATFORM_SRC_OBJECTS_3 = medialib_mediactrl.o
 @COND_TOOLKIT_MOTIF@__MEDIA_PLATFORM_SRC_OBJECTS_3 = 
@@ -13035,6 +13035,9 @@ monodll_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_MAC_USE_GUI_1@monodll_mediactrl.o: $(srcdir)/src/mac/carbon/mediactrl.cpp $(MONODLL_ODEP)
 @COND_TOOLKIT_MAC_USE_GUI_1@   $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/mac/carbon/mediactrl.cpp
 
+@COND_TOOLKIT_COCOA_USE_GUI_1@monodll_mediactrl.o: $(srcdir)/src/cocoa/mediactrl.mm $(MONODLL_ODEP)
+@COND_TOOLKIT_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/cocoa/mediactrl.mm
+
 @COND_PLATFORM_UNIX_1_USE_GUI_1@monodll_chm.o: $(srcdir)/src/html/chm.cpp $(MONODLL_ODEP)
 @COND_PLATFORM_UNIX_1_USE_GUI_1@       $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/html/chm.cpp
 
@@ -16416,6 +16419,9 @@ monolib_gprint.o: $(srcdir)/src/gtk/gnome/gprint.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_MAC_USE_GUI_1@monolib_mediactrl.o: $(srcdir)/src/mac/carbon/mediactrl.cpp $(MONOLIB_ODEP)
 @COND_TOOLKIT_MAC_USE_GUI_1@   $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/mac/carbon/mediactrl.cpp
 
+@COND_TOOLKIT_COCOA_USE_GUI_1@monolib_mediactrl.o: $(srcdir)/src/cocoa/mediactrl.mm $(MONOLIB_ODEP)
+@COND_TOOLKIT_COCOA_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/cocoa/mediactrl.mm
+
 @COND_PLATFORM_UNIX_1_USE_GUI_1@monolib_chm.o: $(srcdir)/src/html/chm.cpp $(MONOLIB_ODEP)
 @COND_PLATFORM_UNIX_1_USE_GUI_1@       $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/html/chm.cpp
 
@@ -22830,6 +22836,9 @@ mediadll_mediactrlcmn.o: $(srcdir)/src/common/mediactrlcmn.cpp $(MEDIADLL_ODEP)
 @COND_TOOLKIT_MAC@mediadll_mediactrl.o: $(srcdir)/src/mac/carbon/mediactrl.cpp $(MEDIADLL_ODEP)
 @COND_TOOLKIT_MAC@     $(CXXC) -c -o $@ $(MEDIADLL_CXXFLAGS) $(srcdir)/src/mac/carbon/mediactrl.cpp
 
+@COND_TOOLKIT_COCOA@mediadll_mediactrl.o: $(srcdir)/src/cocoa/mediactrl.mm $(MEDIADLL_ODEP)
+@COND_TOOLKIT_COCOA@   $(CXXC) -c -o $@ $(MEDIADLL_CXXFLAGS) $(srcdir)/src/cocoa/mediactrl.mm
+
 medialib_mediactrlcmn.o: $(srcdir)/src/common/mediactrlcmn.cpp $(MEDIALIB_ODEP)
        $(CXXC) -c -o $@ $(MEDIALIB_CXXFLAGS) $(srcdir)/src/common/mediactrlcmn.cpp
 
@@ -22842,6 +22851,9 @@ medialib_mediactrlcmn.o: $(srcdir)/src/common/mediactrlcmn.cpp $(MEDIALIB_ODEP)
 @COND_TOOLKIT_MAC@medialib_mediactrl.o: $(srcdir)/src/mac/carbon/mediactrl.cpp $(MEDIALIB_ODEP)
 @COND_TOOLKIT_MAC@     $(CXXC) -c -o $@ $(MEDIALIB_CXXFLAGS) $(srcdir)/src/mac/carbon/mediactrl.cpp
 
+@COND_TOOLKIT_COCOA@medialib_mediactrl.o: $(srcdir)/src/cocoa/mediactrl.mm $(MEDIALIB_ODEP)
+@COND_TOOLKIT_COCOA@   $(CXXC) -c -o $@ $(MEDIALIB_CXXFLAGS) $(srcdir)/src/cocoa/mediactrl.mm
+
 odbcdll_db.o: $(srcdir)/src/common/db.cpp $(ODBCDLL_ODEP)
        $(CXXC) -c -o $@ $(ODBCDLL_CXXFLAGS) $(srcdir)/src/common/db.cpp
 
index 5f86ae24b002ea13bf2fca42d4f6c6f96c00e232..213a31164d1a05e83f7dca45a81a5ec3509acd21 100644 (file)
@@ -2406,6 +2406,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
 </set>
 
 <set var="MEDIA_COCOA_SRC" hints="files">
+    src/cocoa/mediactrl.mm
 </set>
 <set var="MEDIA_COCOA_HDR" hints="files">
 </set>
index c3128b95ea5d5e7128a020a6786c86e18c935ba6..fadc74f1a7ff1064684b433e6813790fa0d782b3 100755 (executable)
--- a/configure
+++ b/configure
@@ -38602,6 +38602,9 @@ if test "$wxUSE_MAC" = 1 ; then
 fi
 if test "$wxUSE_COCOA" = 1 ; then
     LDFLAGS="$LDFLAGS -framework Cocoa"
+    if test "$wxUSE_MEDIACTRL" = "yes"; then
+        LDFLAGS="$LDFLAGS -framework QuickTime"
+    fi
 fi
 
 
index 17194bb98fe4ab5344129e4e64b8ccac4bf2a437..fb2ed7ec749a8a6cbc9b871dbb6b560340b45fdf 100644 (file)
@@ -6062,6 +6062,9 @@ if test "$wxUSE_MAC" = 1 ; then
 fi
 if test "$wxUSE_COCOA" = 1 ; then
     LDFLAGS="$LDFLAGS -framework Cocoa"
+    if test "$wxUSE_MEDIACTRL" = "yes"; then
+        LDFLAGS="$LDFLAGS -framework QuickTime"
+    fi
 fi
 
 dnl FIXME: should this be covered by the conditional above
index d9c9442a96ddc7173fa858270682eee0c43d891d..0e27f8b541f979a8c4e52cc40783e84541e41be9 100644 (file)
@@ -73,8 +73,8 @@ public:
     //
     // Normal constructor, much the same as wxNotifyEvent
     // ------------------------------------------------------------------------
-    wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
-        : wxNotifyEvent(commandType, id)
+    wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
+        : wxNotifyEvent(commandType, winid)
     {                                       }
 
     // ------------------------------------------------------------------------
@@ -112,7 +112,7 @@ public:
     wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
     {                                                                   }
 
-    wxMediaCtrl(wxWindow* parent, wxWindowID id,
+    wxMediaCtrl(wxWindow* parent, wxWindowID winid,
                 const wxString& fileName = wxT(""),
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
@@ -121,10 +121,10 @@ public:
                 const wxValidator& validator = wxDefaultValidator,
                 const wxString& name = wxT("mediaCtrl"))
                 : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
-    {   Create(parent, id, fileName, pos, size, style,
+    {   Create(parent, winid, fileName, pos, size, style,
                szBackend, validator, name);                             }
 
-    wxMediaCtrl(wxWindow* parent, wxWindowID id,
+    wxMediaCtrl(wxWindow* parent, wxWindowID winid,
                 const wxURI& location,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
@@ -133,12 +133,12 @@ public:
                 const wxValidator& validator = wxDefaultValidator,
                 const wxString& name = wxT("mediaCtrl"))
                 : m_imp(NULL), m_bLoop(false)
-    {   Create(parent, id, location, pos, size, style,
+    {   Create(parent, winid, location, pos, size, style,
                szBackend, validator, name);                             }
 
     ~wxMediaCtrl();
 
-    bool Create(wxWindow* parent, wxWindowID id,
+    bool Create(wxWindow* parent, wxWindowID winid,
                 const wxString& fileName = wxT(""),
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
@@ -147,7 +147,7 @@ public:
                 const wxValidator& validator = wxDefaultValidator,
                 const wxString& name = wxT("mediaCtrl"));
 
-    bool Create(wxWindow* parent, wxWindowID id,
+    bool Create(wxWindow* parent, wxWindowID winid,
                 const wxURI& location,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
@@ -157,7 +157,7 @@ public:
                 const wxString& name = wxT("mediaCtrl")); //DirectShow only
 
     bool DoCreate(wxClassInfo* instance,
-                wxWindow* parent, wxWindowID id,
+                wxWindow* parent, wxWindowID winid,
                 const wxPoint& pos = wxDefaultPosition,
                 const wxSize& size = wxDefaultSize,
                 long style = 0,
@@ -192,6 +192,9 @@ protected:
 
 #ifdef __WXMAC__
     friend class wxMediaBackend;
+#endif
+#ifdef __WXCOCOA__
+    friend class wxQTMediaBackend;
 #endif
     class wxMediaBackend* m_imp;
     bool m_bLoaded;
@@ -218,7 +221,7 @@ public:
 
     virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
                                wxWindow* WXUNUSED(parent),
-                               wxWindowID WXUNUSED(id),
+                               wxWindowID WXUNUSED(winid),
                                const wxPoint& WXUNUSED(pos),
                                const wxSize& WXUNUSED(size),
                                long WXUNUSED(style),
diff --git a/src/cocoa/mediactrl.mm b/src/cocoa/mediactrl.mm
new file mode 100644 (file)
index 0000000..0d09279
--- /dev/null
@@ -0,0 +1,506 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        mac/cocoa/mediactrl.cpp
+// Purpose:     Built-in Media Backends for Cocoa
+// Author:      Ryan Norton <wxprojects@comcast.net>
+// Modified by:
+// Created:     02/03/05
+// RCS-ID:      $Id$
+// Copyright:   (c) 2004-2005 Ryan Norton, (c) 2005 David Elliot
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+//===========================================================================
+//  DECLARATIONS
+//===========================================================================
+
+//---------------------------------------------------------------------------
+// Pre-compiled header stuff
+//---------------------------------------------------------------------------
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+#pragma implementation "mediactrl.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+//---------------------------------------------------------------------------
+// Includes
+//---------------------------------------------------------------------------
+#include "wx/mediactrl.h"
+
+//---------------------------------------------------------------------------
+// Compilation guard
+//---------------------------------------------------------------------------
+#if wxUSE_MEDIACTRL
+
+//===========================================================================
+//  BACKEND DECLARATIONS
+//===========================================================================
+
+//---------------------------------------------------------------------------
+//
+//  wxQTMediaBackend
+//
+//---------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------
+//  QT Includes
+//---------------------------------------------------------------------------
+#include "wx/timer.h"
+#include <QuickTime/QuickTime.h>
+
+#include "wx/cocoa/autorelease.h"
+#include "wx/cocoa/string.h"
+
+#import <AppKit/NSMovie.h>
+#import <AppKit/NSMovieView.h>
+
+
+class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackend
+{
+public:
+
+    wxQTMediaBackend();
+    ~wxQTMediaBackend();
+
+    virtual bool CreateControl(wxControl* ctrl, wxWindow* parent, 
+                                     wxWindowID id,
+                                     const wxPoint& pos, 
+                                     const wxSize& size,
+                                     long style, 
+                                     const wxValidator& validator,
+                                     const wxString& name);
+
+    virtual bool Play();
+    virtual bool Pause();
+    virtual bool Stop();
+
+    virtual bool Load(const wxString& fileName);
+    virtual bool Load(const wxURI& location);
+
+    virtual wxMediaState GetState();
+
+    virtual bool SetPosition(wxLongLong where);
+    virtual wxLongLong GetPosition();
+    virtual wxLongLong GetDuration();
+
+    virtual void Move(int x, int y, int w, int h);
+    wxSize GetVideoSize() const;
+
+    virtual double GetPlaybackRate();
+    virtual bool SetPlaybackRate(double dRate);
+
+    void Cleanup();
+    void FinishLoad();
+
+    wxSize m_bestSize;              //Original movie size
+    Movie m_movie;                             //QT Movie handle/instance
+    NSMovieView* m_movieview;       //NSMovieView instance
+    wxControl* m_ctrl;              //Parent control
+    bool m_bVideo;                  //Whether or not we have video
+    class _wxQTTimer* m_timer;      //Timer for streaming the movie
+
+    DECLARE_DYNAMIC_CLASS(wxQTMediaBackend);
+};
+
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// wxQTMediaBackend
+// 
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend);
+
+//Time between timer calls
+#define MOVIE_DELAY 100
+
+// --------------------------------------------------------------------------
+//          wxQTTimer - Handle Asyncronous Playing
+// --------------------------------------------------------------------------
+class _wxQTTimer : public wxTimer
+{
+public:
+    _wxQTTimer(Movie movie, wxQTMediaBackend* parent) :
+        m_movie(movie), m_bPaused(false), m_parent(parent)
+    {
+    }
+
+    ~_wxQTTimer()
+    {
+    }
+
+    bool GetPaused() {return m_bPaused;}
+    void SetPaused(bool bPaused) {m_bPaused = bPaused;}
+
+    //-----------------------------------------------------------------------
+    // _wxQTTimer::Notify
+    //
+    // 1) Checks to see if the movie is done, and if not continues
+    //    streaming the movie
+    // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
+    //    the movie.
+    //-----------------------------------------------------------------------
+    void Notify()
+    {
+        if (!m_bPaused)
+        {
+            if(!IsMovieDone(m_movie))
+                MoviesTask(m_movie, MOVIE_DELAY); 
+            else
+            {
+                wxMediaEvent theEvent(wxEVT_MEDIA_STOP, 
+                                      m_parent->m_ctrl->GetId());
+                m_parent->m_ctrl->ProcessEvent(theEvent);
+
+                if(theEvent.IsAllowed())
+                {
+                    Stop();
+                    m_parent->Stop();
+                    wxASSERT(::GetMoviesError() == noErr);
+
+                    //send the event to our child
+                    wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, 
+                                          m_parent->m_ctrl->GetId());
+                    m_parent->m_ctrl->ProcessEvent(theEvent);
+                }
+            }
+        }
+    }
+
+protected:
+    Movie m_movie;                  //Our movie instance
+    bool m_bPaused;                 //Whether we are paused or not
+    wxQTMediaBackend* m_parent;     //Backend pointer
+};
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend Constructor
+//
+// Sets m_timer to NULL signifying we havn't loaded anything yet
+//---------------------------------------------------------------------------
+wxQTMediaBackend::wxQTMediaBackend() : m_timer(NULL)
+{
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend Destructor
+//
+// 1) Cleans up the QuickTime movie instance
+// 2) Decrements the QuickTime reference counter - if this reaches
+//    0, QuickTime shuts down
+// 3) Decrements the QuickTime Windows Media Layer reference counter -
+//    if this reaches 0, QuickTime shuts down the Windows Media Layer
+//---------------------------------------------------------------------------
+wxQTMediaBackend::~wxQTMediaBackend()
+{
+    if(m_timer)
+        Cleanup();
+
+    //Note that ExitMovies() is not neccessary...
+    ExitMovies();
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::CreateControl
+//
+// 1) Intializes QuickTime
+// 2) Creates the control window
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::CreateControl(wxControl* inctrl, wxWindow* parent, 
+                                     wxWindowID wid,
+                                     const wxPoint& pos, 
+                                     const wxSize& size,
+                                     long style, 
+                                     const wxValidator& validator,
+                                     const wxString& name)
+{
+    EnterMovies();
+    
+    wxMediaCtrl* ctrl = (wxMediaCtrl*) inctrl;
+
+    //Create the control base
+    wxASSERT(ctrl->CreateBase(parent,wid,pos,size,style, validator, size));
+    
+    //Create the NSMovieView
+    ctrl->SetNSView(NULL);
+    NSView* theView = [[NSMovieView alloc] initWithFrame: ctrl->MakeDefaultNSRect(size)];
+    ctrl->SetNSView(theView);
+    [theView release];
+
+    if (parent)
+    {
+        parent->AddChild(ctrl);
+        parent->CocoaAddChild(ctrl);
+        ctrl->SetInitialFrameRect(pos,size);
+    }
+    
+    m_movieview = theView;
+    m_ctrl = ctrl;
+    return true;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Load (file version)
+//
+// Calls the URI version
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::Load(const wxString& fileName)
+{
+    return Load(
+                wxURI(
+                    wxString( wxT("file://") ) + fileName 
+                     )
+               );
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Load (URL Version)
+//
+// 1) Build an escaped URI from location
+// ...
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::Load(const wxURI& location)
+{
+    if(m_timer)
+        Cleanup();
+
+    wxString theURI = location.BuildURI();
+
+    [m_movieview setMovie:[[NSMovie alloc] initWithURL: [NSURL URLWithString: wxNSStringWithWxString(theURI)]
+                               byReference: YES ] ];
+
+    m_movie = (Movie) [[m_movieview movie] QTMovie];
+
+    //preroll movie for streaming
+    //TODO:Async this using threads?
+    TimeValue timeNow;
+    Fixed playRate;
+    timeNow = GetMovieTime(m_movie, NULL);
+    playRate = GetMoviePreferredRate(m_movie);
+    PrePrerollMovie(m_movie, timeNow, playRate, NULL, NULL);
+    PrerollMovie(m_movie, timeNow, playRate);
+    SetMovieRate(m_movie, playRate);
+
+    FinishLoad();
+
+    return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::FinishLoad
+//
+// 1) Create the movie timer
+// 2) Get real size of movie for GetBestSize/sizers
+// 3) See if there is video in the movie, and if so then either
+//    SetMovieGWorld if < 10.2 or use Native CreateMovieControl
+// 4) Set the movie time scale to something usable so that seeking
+//    etc.  will work correctly
+// 5) Refresh parent window
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::FinishLoad()
+{
+    m_timer = new _wxQTTimer(m_movie, (wxQTMediaBackend*) this);
+    wxASSERT(m_timer);
+
+    //get the real size of the movie
+    Rect outRect;
+    ::GetMovieNaturalBoundsRect (m_movie, &outRect);
+    wxASSERT(::GetMoviesError() == noErr);
+
+    m_bestSize.x = outRect.right - outRect.left;
+    m_bestSize.y = outRect.bottom - outRect.top;
+
+    //we want millisecond precision
+    ::SetMovieTimeScale(m_movie, 1000);
+    wxASSERT(::GetMoviesError() == noErr);
+
+    //
+    //Here, if the parent of the control has a sizer - we
+    //tell it to recalculate the size of this control since
+    //the user opened a seperate media file
+    //
+    m_ctrl->InvalidateBestSize();
+    m_ctrl->GetParent()->Layout();
+    m_ctrl->GetParent()->Refresh();
+    m_ctrl->GetParent()->Update();
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Play
+//
+// 1) Start the QT movie
+// 2) Start the movie loading timer
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::Play()
+{
+    ::StartMovie(m_movie);
+    m_timer->SetPaused(false);
+    m_timer->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS);
+    return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Pause
+//
+// 1) Stop the movie
+// 2) Stop the movie timer
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::Pause()
+{
+    ::StopMovie(m_movie);
+    m_timer->SetPaused(true);
+    m_timer->Stop();
+    return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Stop
+//
+// 1) Stop the movie
+// 2) Stop the movie timer
+// 3) Seek to the beginning of the movie
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::Stop()
+{
+    m_timer->SetPaused(false);
+    m_timer->Stop();
+
+    ::StopMovie(m_movie);
+    if(::GetMoviesError() != noErr)
+        return false;
+    
+    ::GoToBeginningOfMovie(m_movie);
+    return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetPlaybackRate
+//
+// 1) Get the movie playback rate from ::GetMovieRate
+//---------------------------------------------------------------------------
+double wxQTMediaBackend::GetPlaybackRate()
+{
+    return ( ((double)::GetMovieRate(m_movie)) / 0x10000);
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::SetPlaybackRate
+//
+// 1) Convert dRate to Fixed and Set the movie rate through SetMovieRate
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::SetPlaybackRate(double dRate)
+{
+    ::SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
+    return ::GetMoviesError() == noErr;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::SetPosition
+//
+// 1) Create a time record struct (TimeRecord) with appropriate values
+// 2) Pass struct to SetMovieTime
+//---------------------------------------------------------------------------
+bool wxQTMediaBackend::SetPosition(wxLongLong where)
+{
+    TimeRecord theTimeRecord;
+    memset(&theTimeRecord, 0, sizeof(TimeRecord));
+    theTimeRecord.value.lo = where.GetValue();
+    theTimeRecord.scale = ::GetMovieTimeScale(m_movie);
+    theTimeRecord.base = ::GetMovieTimeBase(m_movie);
+    ::SetMovieTime(m_movie, &theTimeRecord);
+
+    if (::GetMoviesError() != noErr)
+        return false;
+
+    return true;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetPosition
+//
+// Calls GetMovieTime
+//---------------------------------------------------------------------------
+wxLongLong wxQTMediaBackend::GetPosition()
+{
+    return ::GetMovieTime(m_movie, NULL);
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetDuration
+//
+// Calls GetMovieDuration
+//---------------------------------------------------------------------------
+wxLongLong wxQTMediaBackend::GetDuration()
+{
+    return ::GetMovieDuration(m_movie);
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetState
+//
+// Determines the current state - the timer keeps track of whether or not
+// we are paused or stopped (if the timer is running we are playing)
+//---------------------------------------------------------------------------
+wxMediaState wxQTMediaBackend::GetState()
+{
+    if ( !m_timer || (m_timer->IsRunning() == false && 
+                      m_timer->GetPaused() == false) )
+        return wxMEDIASTATE_STOPPED;
+
+    if( m_timer->IsRunning() == true )
+        return wxMEDIASTATE_PLAYING;
+    else
+        return wxMEDIASTATE_PAUSED;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Cleanup
+//
+// Diposes of the movie timer, Control if native, and stops and disposes
+// of the QT movie
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::Cleanup()
+{
+    delete m_timer;
+    m_timer = NULL;
+
+    [[m_movieview movie] release];
+    [m_movieview setMovie:NULL];
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::GetVideoSize
+//
+// Returns the actual size of the QT movie
+//---------------------------------------------------------------------------
+wxSize wxQTMediaBackend::GetVideoSize() const
+{
+    return m_bestSize;
+}
+
+//---------------------------------------------------------------------------
+// wxQTMediaBackend::Move
+//
+// Nothin... cocoa takes care of this for us
+//---------------------------------------------------------------------------
+void wxQTMediaBackend::Move(int x, int y, int w, int h)
+{
+}
+
+
+//in source file that contains stuff you don't directly use
+#include <wx/html/forcelnk.h>
+FORCE_LINK_ME(basewxmediabackends);
+
+#endif //wxUSE_MEDIACTRL
+
+
+
+
+