tweak stopping - nicen up sample some more
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30467 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -330,7 +330,7 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
|
|
||||||
//
|
//
|
||||||
//~MyFrame
|
//~MyFrame
|
||||||
//-------
|
//--------
|
||||||
//Deletes child objects implicitly and our timer explicitly
|
//Deletes child objects implicitly and our timer explicitly
|
||||||
//
|
//
|
||||||
MyFrame::~MyFrame()
|
MyFrame::~MyFrame()
|
||||||
@@ -340,7 +340,7 @@ MyFrame::~MyFrame()
|
|||||||
|
|
||||||
//
|
//
|
||||||
//OnQuit
|
//OnQuit
|
||||||
//-------
|
//------
|
||||||
//Called from file->quit.
|
//Called from file->quit.
|
||||||
//Closes this application.
|
//Closes this application.
|
||||||
//
|
//
|
||||||
@@ -367,7 +367,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
//
|
//
|
||||||
//OnLoop
|
//OnLoop
|
||||||
//-------
|
//------
|
||||||
//Called from file->loop.
|
//Called from file->loop.
|
||||||
//Changes the state of whether we want to loop or not.
|
//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.
|
//Called from file->openfile.
|
||||||
//Opens and plays a media file
|
//Opens and plays a media file
|
||||||
//
|
//
|
||||||
@@ -400,7 +400,7 @@ void MyFrame::OnOpenFile(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
//
|
//
|
||||||
//OnPlay
|
//OnPlay
|
||||||
//-------
|
//------
|
||||||
//Called from file->play.
|
//Called from file->play.
|
||||||
//Resumes the media if it is paused or stopped.
|
//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 -
|
//Where it stops depends on whether you can seek in the
|
||||||
//it could stop at the end or beginning.
|
//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 from file->seek.
|
||||||
//Called when the user moves the slider -
|
//Called when the user moves the slider -
|
||||||
//seeks to a position within the media
|
//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.
|
//Called when the media stops playing.
|
||||||
//Here we loop it if the user wants to (has been selected from file menu)
|
//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() )
|
if ( !m_mediactrl->Play() )
|
||||||
wxMessageBox(wxT("Couldn't seek or play to loop movie!"));
|
wxMessageBox(wxT("Couldn't loop movie!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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 this is the end of the clip, notify handler
|
||||||
if(EC_COMPLETE == evCode)
|
if(EC_COMPLETE == evCode)
|
||||||
{
|
{
|
||||||
|
//Interestingly enough, DirectShow does not actually stop
|
||||||
|
//the filters - even when it reaches the end!
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
wxASSERT( Stop() );
|
wxASSERT( Stop() );
|
||||||
#else
|
#else
|
||||||
Stop();
|
Stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, m_ctrl->GetId());
|
wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, m_ctrl->GetId());
|
||||||
m_ctrl->GetParent()->ProcessEvent(theEvent);
|
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"
|
||||||
|
Reference in New Issue
Block a user