]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMediaCtrl API changes for 2.5.x/2.6
authorRyan Norton <wxprojects@comcast.net>
Fri, 17 Dec 2004 16:07:21 +0000 (16:07 +0000)
committerRyan Norton <wxprojects@comcast.net>
Fri, 17 Dec 2004 16:07:21 +0000 (16:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31051 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/mediactrl.tex
include/wx/mediactrl.h
samples/mediaplayer/mediaplayer.cpp
src/common/mediactrlcmn.cpp

index 77c4ffe93e617d1dba6d0445daa5395f54589ef5..f12d8b0ab6d040116af4a799c5f8182e37efe0d1 100644 (file)
@@ -172,16 +172,16 @@ wxMediaCtrl figure it out.}
 \docparam{name}{Window name.}
 
 
-\membersection{wxMediaCtrl::GetDuration}\label{wxmediactrlgetduration}
+\membersection{wxMediaCtrl::Length}\label{wxmediactrlgetduration}
 
-\func{wxLongLong}{GetDuration}{\void}
+\func{wxFileOffset}{GetDuration}{\void}
 
 Obtains the length - the total amount of time the movie has in milliseconds.
 
 
-\membersection{wxMediaCtrl::GetPosition}\label{wxmediactrlgetposition}
+\membersection{wxMediaCtrl::Tell}\label{wxmediactrlgetposition}
 
-\func{wxLongLong}{GetPosition}{\void}
+\func{wxFileOffset}{GetPosition}{\void}
 
 Obtains the current position in time within the movie in milliseconds.
 
@@ -220,9 +220,9 @@ Pauses playback of the movie.
 Resumes playback of the movie.
 
 
-\membersection{wxMediaCtrl::SetPosition}\label{wxmediactrlsetposition}
+\membersection{wxMediaCtrl::Seek}\label{wxmediactrlsetposition}
 
-\func{bool}{SetPosition}{\param{wxLongLong }{where}}
+\func{wxFileOffset}{SetPosition}{\param{wxFileOffset }{where}, \param{wxSeekMode }{mode}}
 
 Seeks to a position within the movie.
 
index 7994c83ea210f96c417bfeaf0f2c3492a453af91..7ee066d29f3e2e2905ef9fa0f6614b382e1f24f9 100644 (file)
@@ -55,11 +55,6 @@ enum wxMediaState
     wxMEDIASTATE_PLAYING
 };
 
-enum wxMediaTimeFormat
-{
-    wxMEDIATIMEFORMAT_TIME
-};
-
 #define wxMEDIABACKEND_DIRECTSHOW   wxT("wxAMMediaBackend")
 #define wxMEDIABACKEND_MCI          wxT("wxMCIMediaBackend")
 #define wxMEDIABACKEND_QUICKTIME    wxT("wxQTMediaBackend")
@@ -159,7 +154,7 @@ public:
                 long style = 0,
                 const wxString& szBackend = wxT(""),
                 const wxValidator& validator = wxDefaultValidator,
-                const wxString& name = wxT("mediaCtrl"));
+                const wxString& name = wxT("mediaCtrl")); //DirectShow only
 
     bool DoCreate(wxClassInfo* instance,
                 wxWindow* parent, wxWindowID id,
@@ -174,26 +169,19 @@ public:
     bool Stop();
 
     bool Load(const wxString& fileName);
-    bool Load(const wxURI& location);
+    bool Load(const wxURI& location); //DirectShow only
 
     void Loop(bool bLoop = true);
     bool IsLooped();
 
     wxMediaState GetState();
 
-    double GetPlaybackRate();
-    bool SetPlaybackRate(double dRate);
-
-    bool SetPosition(wxLongLong where);
-    wxLongLong GetPosition();
-    wxLongLong GetDuration();
-
-    //The following two prevent function hiding
-    void GetPosition(int* x, int* y) const
-    {       wxControl::GetPosition(x, y);           }
+    double GetPlaybackRate();           //All but MCI
+    bool SetPlaybackRate(double dRate); //All but MCI
 
-    wxPoint GetPosition() const
-    {       return wxControl::GetPosition();        }  
+    wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
+    wxFileOffset Tell(); //FIXME: This should be const
+    wxFileOffset Length(); //FIXME: This should be const
 
 protected:
     static wxClassInfo* NextBackend();
@@ -213,7 +201,7 @@ protected:
 //
 // wxMediaBackend
 //
-// Currently an internal class - API stability not gauranteed.
+// Currently an internal class - API stability not guaranteed.
 //
 // ----------------------------------------------------------------------------
 
index 87561fd4f92d0efbc29a362854d289f23eede50b..d24c54c84d4584571f6581e0f036b67a839fb27b 100644 (file)
@@ -244,6 +244,7 @@ bool MyApp::OnInit()
 // 4) Connect our events
 // 5) Start our timer
 // ----------------------------------------------------------------------------
+
 MyFrame::MyFrame(const wxString& title)
        : wxFrame(NULL, wxID_ANY, title)
 {
@@ -482,11 +483,11 @@ void MyFrame::ResetStatus()
                                     _T("Length(Seconds):%u Speed:%1.1fx"),
     m_mediactrl->GetBestSize().x,
     m_mediactrl->GetBestSize().y,
-    (unsigned)((m_mediactrl->GetDuration() / 1000).ToLong()),
+    (unsigned)((m_mediactrl->Length() / 1000)),
     m_mediactrl->GetPlaybackRate()
     );
 
-    m_slider->SetRange(0, (m_mediactrl->GetDuration() / 1000).ToLong());
+    m_slider->SetRange(0, (m_mediactrl->Length() / 1000));
 
     m_nLoops = 0;
 }
@@ -599,7 +600,7 @@ void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void MyFrame::OnSeek(wxCommandEvent& WXUNUSED(event))
 {
-    if( !m_mediactrl->SetPosition( m_slider->GetValue() * 1000 ) )
+    if( m_mediactrl->Seek( m_slider->GetValue() * 1000 ) == wxInvalidOffset )
         wxMessageBox(wxT("Couldn't seek in movie!"));
 }
 
@@ -630,7 +631,7 @@ void MyFrame::OnMediaStop(wxMediaEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void MyTimer::Notify()
 {
-    long lPosition = (m_frame->m_mediactrl->GetPosition() / 1000).ToLong();
+    long lPosition = (m_frame->m_mediactrl->Tell() / 1000);
     m_frame->m_slider->SetValue(lPosition);
 
 #if wxUSE_STATUSBAR
index 0a6665b37330db8c92bffa367515ca8e7139e05f..51ba32f6c858f47ec38216934bf146919c6c7a5e 100644 (file)
@@ -70,7 +70,7 @@ DEFINE_EVENT_TYPE(wxEVT_MEDIA_STOP);
 //
 // This searches by searching the global RTTI hashtable, class by class,
 // attempting to call CreateControl on each one found that is a derivative
-// of wxMediaBackend - if it succeededs Create returns true, otherwise
+// of wxMediaBackend - if it succeeded Create returns true, otherwise
 // it keeps iterating through the hashmap.
 //---------------------------------------------------------------------------
 bool wxMediaCtrl::Create(wxWindow* parent, wxWindowID id,
@@ -301,9 +301,9 @@ bool wxMediaCtrl::Load(const wxURI& location)
 // wxMediaCtrl::Stop
 // wxMediaCtrl::GetPlaybackRate
 // wxMediaCtrl::SetPlaybackRate
-// wxMediaCtrl::SetPosition
-// wxMediaCtrl::GetPosition
-// wxMediaCtrl::GetDuration
+// wxMediaCtrl::Seek --> SetPosition
+// wxMediaCtrl::Tell --> GetPosition
+// wxMediaCtrl::Length --> GetDuration
 // wxMediaCtrl::GetState
 // wxMediaCtrl::DoGetBestSize
 //
@@ -346,25 +346,43 @@ bool wxMediaCtrl::SetPlaybackRate(double dRate)
     return false;
 }
 
-bool wxMediaCtrl::SetPosition(wxLongLong where)
+wxFileOffset wxMediaCtrl::Seek(wxFileOffset where, wxSeekMode mode)
 {
-    if(m_imp && m_bLoaded)
-        return m_imp->SetPosition(where);
-    return false;
+    wxFileOffset offset;
+
+    switch (mode)
+    {
+    case wxFromStart:
+        offset = where;
+        break;
+    case wxFromEnd:
+        offset = Length() - where;
+        break;
+//    case wxFromCurrent:
+    default:
+        offset = Tell() + where;
+        break;
+    }
+
+    if(m_imp && m_bLoaded && m_imp->SetPosition(offset))
+        return offset;
+    return wxInvalidOffset;
 }
 
-wxLongLong wxMediaCtrl::GetPosition()
+wxFileOffset wxMediaCtrl::Tell()
 {
+    //FIXME
     if(m_imp && m_bLoaded)
-        return m_imp->GetPosition();
-    return 0;
+        return (wxFileOffset) m_imp->GetPosition().ToLong();
+    return wxInvalidOffset;
 }
 
-wxLongLong wxMediaCtrl::GetDuration()
+wxFileOffset wxMediaCtrl::Length()
 {
+    //FIXME
     if(m_imp && m_bLoaded)
-        return m_imp->GetDuration();
-    return 0;
+        return (wxFileOffset) m_imp->GetDuration().ToLong();
+    return wxInvalidOffset;
 }
 
 wxMediaState wxMediaCtrl::GetState()