]> git.saurik.com Git - wxWidgets.git/commitdiff
tweak stopping - nicen up sample some more
authorRyan Norton <wxprojects@comcast.net>
Thu, 11 Nov 2004 15:18:18 +0000 (15:18 +0000)
committerRyan Norton <wxprojects@comcast.net>
Thu, 11 Nov 2004 15:18:18 +0000 (15:18 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/mediaplayer/mediaplayer.cpp
src/msw/mediactrl.cpp

index faf3dbfc230560480b45a75681c99a73a210a3b6..8a4756a2226e481a5d68af60b7fc04e65c37e4d6 100644 (file)
@@ -330,7 +330,7 @@ MyFrame::MyFrame(const wxString& title)
 
 //
 //~MyFrame
 
 //
 //~MyFrame
-//-------
+//--------
 //Deletes child objects implicitly and our timer explicitly
 //
 MyFrame::~MyFrame()
 //Deletes child objects implicitly and our timer explicitly
 //
 MyFrame::~MyFrame()
@@ -340,7 +340,7 @@ MyFrame::~MyFrame()
 
 //
 //OnQuit
 
 //
 //OnQuit
-//-------
+//------
 //Called from file->quit.
 //Closes this application.
 //
 //Called from file->quit.
 //Closes this application.
 //
@@ -367,7 +367,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnLoop
 
 //
 //OnLoop
-//-------
+//------
 //Called from file->loop.
 //Changes the state of whether we want to loop or not.
 //
 //Called from file->loop.
 //Changes the state of whether we want to loop or not.
 //
@@ -378,7 +378,7 @@ void MyFrame::OnLoop(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnOpenFile
 
 //
 //OnOpenFile
-//-------
+//----------
 //Called from file->openfile.
 //Opens and plays a media file
 //
 //Called from file->openfile.
 //Opens and plays a media file
 //
@@ -400,7 +400,7 @@ void MyFrame::OnOpenFile(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnPlay
 
 //
 //OnPlay
-//-------
+//------
 //Called from file->play.
 //Resumes the media if it is paused or stopped.
 //
 //Called from file->play.
 //Resumes the media if it is paused or stopped.
 //
@@ -424,10 +424,12 @@ void MyFrame::OnPause(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnStop
 
 //
 //OnStop
-//-------
+//------
 //Called from file->stop.
 //Called from file->stop.
-//Note that where the media stops is undefined - 
-//it could stop at the end or beginning.
+//Where it stops depends on whether you can seek in the
+//media control or not - if you can it stops and seeks to the beginning,
+//otherwise it will appear to be at the end - but it will start over again
+//when play() is called
 //
 void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event))
 {
 //
 void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event))
 {
@@ -437,7 +439,7 @@ void MyFrame::OnStop(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnSeek
 
 //
 //OnSeek
-//-------
+//------
 //Called from file->seek.
 //Called when the user moves the slider -
 //seeks to a position within the media
 //Called from file->seek.
 //Called when the user moves the slider -
 //seeks to a position within the media
@@ -450,7 +452,7 @@ void MyFrame::OnSeek(wxCommandEvent& WXUNUSED(event))
 
 //
 //OnMediaFinished
 
 //
 //OnMediaFinished
-//-------
+//---------------
 //Called when the media stops playing.
 //Here we loop it if the user wants to (has been selected from file menu)
 //
 //Called when the media stops playing.
 //Here we loop it if the user wants to (has been selected from file menu)
 //
@@ -458,7 +460,7 @@ void MyFrame::OnMediaFinished(wxMediaEvent& WXUNUSED(event))
 {
     if(m_bLoop)
     {
 {
     if(m_bLoop)
     {
-        if ( !m_mediactrl->SetPosition(0) || !m_mediactrl->Play() )
-            wxMessageBox(wxT("Couldn't seek or play to loop movie!"));
+        if ( !m_mediactrl->Play() )
+            wxMessageBox(wxT("Couldn't loop movie!"));
     }
 }
\ No newline at end of file
     }
 }
\ No newline at end of file
index 96c8361634ef4e49763b2bf7f3428d69549b0058..8362224bd918647cdb5e60cc9ca99d07f07f03d3 100644 (file)
@@ -531,7 +531,13 @@ bool wxDXMediaCtrlImpl::Pause()
 
 bool wxDXMediaCtrlImpl::Stop()
 {
 
 bool wxDXMediaCtrlImpl::Stop()
 {
-    return SUCCEEDED( m_pMC->Stop() ) && SetPosition(0);
+    bool bOK = SUCCEEDED( m_pMC->Stop() );
+
+    //We don't care if it can't get to the beginning in directshow -
+    //it could be a non-seeking filter (wince midi) in which case playing
+    //starts all over again
+    SetPosition(0);
+    return bOK;
 }
 
 bool wxDXMediaCtrlImpl::SetPosition(long where)
 }
 
 bool wxDXMediaCtrlImpl::SetPosition(long where)
@@ -613,11 +619,14 @@ bool wxDXMediaCtrlImpl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa
             // If this is the end of the clip, notify handler
             if(EC_COMPLETE == evCode)
             {
             // If this is the end of the clip, notify handler
             if(EC_COMPLETE == evCode)
             {
+                //Interestingly enough, DirectShow does not actually stop
+                //the filters - even when it reaches the end!
 #ifdef __WXDEBUG__
                 wxASSERT( Stop() );
 #else
                 Stop();
 #endif
 #ifdef __WXDEBUG__
                 wxASSERT( Stop() );
 #else
                 Stop();
 #endif
+
                 wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, m_ctrl->GetId());
                 m_ctrl->GetParent()->ProcessEvent(theEvent);
             }
                 wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, m_ctrl->GetId());
                 m_ctrl->GetParent()->ProcessEvent(theEvent);
             }
@@ -703,7 +712,8 @@ bool wxWMMEMediaCtrlImpl::Pause()
 
 bool wxWMMEMediaCtrlImpl::Stop()
 {
 
 bool wxWMMEMediaCtrlImpl::Stop()
 {
-    return (mciSendCommand(m_hDev, MCI_STOP, MCI_WAIT, 0) == 0);
+    return (mciSendCommand(m_hDev, MCI_STOP, MCI_WAIT, 0) == 0) &&
+            SetPosition(GetDuration());
 }
 
 #include "wx/log.h"
 }
 
 #include "wx/log.h"