//
//~MyFrame
-//-------
+//--------
//Deletes child objects implicitly and our timer explicitly
//
MyFrame::~MyFrame()
//
//OnQuit
-//-------
+//------
//Called from file->quit.
//Closes this application.
//
//
//OnLoop
-//-------
+//------
//Called from file->loop.
//Changes the state of whether we want to loop or not.
//
//
//OnOpenFile
-//-------
+//----------
//Called from file->openfile.
//Opens and plays a media file
//
//
//OnPlay
-//-------
+//------
//Called from file->play.
//Resumes the media if it is paused or stopped.
//
//
//OnStop
-//-------
+//------
//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))
{
//
//OnSeek
-//-------
+//------
//Called from file->seek.
//Called when the user moves the slider -
//seeks to a position within the media
//
//OnMediaFinished
-//-------
+//---------------
//Called when the media stops playing.
//Here we loop it if the user wants to (has been selected from file menu)
//
{
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
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)
// 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
+
wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED, m_ctrl->GetId());
m_ctrl->GetParent()->ProcessEvent(theEvent);
}
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"