// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// MediaPlayer
//
-// This is a simple example of how to use all the funtionality of
+// This is a simple example of how to use all the funtionality of
// the wxMediaCtrl class in wxWidgets.
//
// To use this sample, simply select Open File from the file menu,
#include "wx/textdlg.h" //for getting user text from OpenURL
// ----------------------------------------------------------------------------
-// Bail out if the user doesn't want one of the
+// Bail out if the user doesn't want one of the
// things we need
// ----------------------------------------------------------------------------
// the wxApp exists, and thus will crash the application if you try it.
//
// IMPLEMENT_APP does this, and also implements the platform-specific entry
-// routine, such as main or WinMain(). Use IMPLEMENT_APP_NO_MAIN if you do
+// routine, such as main or WinMain(). Use IMPLEMENT_APP_NO_MAIN if you do
// not desire this behavior.
// ----------------------------------------------------------------------------
IMPLEMENT_APP(MyApp)
// 4) Connect our events
// 5) Start our timer
// ----------------------------------------------------------------------------
+
MyFrame::MyFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title)
{
wxMenu *menuFile = new wxMenu;
wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(wxID_ABOUT,
- _T("&About...\tF1"),
+ helpMenu->Append(wxID_ABOUT,
+ _T("&About...\tF1"),
_T("Show about dialog"));
menuFile->Append(wxID_OPENFILE, _T("&Open File"), _T("Open a File"));
menuFile->Append(wxID_PAUSE, _T("P&ause"), _T("Pause playback"));
menuFile->Append(wxID_STOP, _T("&Stop"), _T("Stop playback"));
menuFile->AppendSeparator();
- menuFile->AppendCheckItem(wxID_LOOP,
- _T("&Loop"),
+ menuFile->AppendCheckItem(wxID_LOOP,
+ _T("&Loop"),
_T("Loop Selected Media"));
menuFile->AppendSeparator();
- menuFile->Append(wxID_EXIT,
- _T("E&xit\tAlt-X"),
+ menuFile->Append(wxID_EXIT,
+ _T("E&xit\tAlt-X"),
_T("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar();
ResetStatus();
SetStatusText(m_basestatus);
#endif // wxUSE_STATUSBAR
-
+
//
// Connect events.
- //
+ //
// There are two ways in wxWidgets to use events -
// Message Maps and Connections.
//
// END_EVENT_TABLE()
//
// Where MyFrame is the class with the DECLARE_MESSAGE_MAP
- // in it. EVT_XXX(XXX) are each of your handlers, such
+ // in it. EVT_XXX(XXX) are each of your handlers, such
// as EVT_MENU for menu events and the XXX inside
// is the parameters to the event macro - in the case
// of EVT_MENU the menu id and then the function to call.
//
// The third is the function handler for the event -
// You need to cast it to the specific event handler
- // type, then to a wxEventFunction, then to a
+ // type, then to a wxEventFunction, then to a
// wxObjectEventFunction - I.E.
// (wxObjectEventFunction)(wxEventFunction)
// (wxCommandEventFunction) &MyFrame::MyHandler
//
- // The fourth is an optional userdata param -
+ // The fourth is an optional userdata param -
// this is of historical relevance only and is
// there only for backwards compatability.
//
// The fifth is the context in which to call the
// handler - by default (this param is optional)
// this. For example in your event handler
- // if you were to call "this->MyFunc()"
+ // if you were to call "this->MyFunc()"
// it would literally do this->MyFunc. However,
// if you were to pass myHandler as the fifth
// parameter, for instance, you would _really_
//
// Menu events
//
- this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnQuit);
-
- this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+
+ this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnAbout);
- this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnLoop);
- this->Connect(wxID_OPENFILE, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_OPENFILE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnOpenFile);
- this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnPlay);
- this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnPause);
- this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnStop);
//
// Slider events
//
- this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnSeek);
//
// Media Control events
//
- this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_STOP,
- (wxObjectEventFunction) (wxEventFunction)
- (wxCommandEventFunction) &MyFrame::OnMediaStop);
+ this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_STOP,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxMediaEventFunction) &MyFrame::OnMediaStop);
//
// End of Events
// ----------------------------------------------------------------------------
// MyFrame Destructor
//
-// 1) Deletes child objects implicitly
+// 1) Deletes child objects implicitly
// 2) Delete our timer explicitly
// ----------------------------------------------------------------------------
MyFrame::~MyFrame()
// ----------------------------------------------------------------------------
// MyFrame::ResetStatus
//
-// Here we just make a simple status string with some useful info about
+// Here we just make a simple status string with some useful info about
// the media that we won't change later - such as the length of the media.
//
// We then append some other info that changes in MyTimer::Notify, then
-// set the status bar to this text.
+// set the status bar to this text.
//
// In real applications, you'd want to find a better way to do this,
// such as static text controls (wxStaticText).
-//
-// We display info here in seconds (wxMediaCtrl uses milliseconds - that's why
+//
+// We display info here in seconds (wxMediaCtrl uses milliseconds - that's why
// we divide by 1000).
//
// We also reset our loop counter here.
_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;
}
// ----------------------------------------------------------------------------
// MyFrame::OnAbout
-//
+//
// Called from help->about.
// Gets some info about this application.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnPlay
-//
+//
// Called from file->play.
// Resumes the media if it is paused or stopped.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnPause
-//
+//
// Called from file->pause.
// Pauses the media in-place.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnStop
-//
+//
// Called from file->stop.
// 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,
// ----------------------------------------------------------------------------
// MyFrame::OnSeek
-//
+//
// Called from file->seek.
// Called when the user moves the slider -
// seeks to a position within the media
// ----------------------------------------------------------------------------
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!"));
}
// ----------------------------------------------------------------------------
// MyFrame::OnMediaStop
-//
+//
// Called when the media is about to stop playing.
// Here we just increase our loop counter
// ----------------------------------------------------------------------------
//
// 1) Update our slider with the position were are in in the media
// 2) Update our status bar with the base text from MyFrame::ResetStatus,
-// append some non-static (changing) info to it, then set the
+// append some non-static (changing) info to it, then set the
// status bar text to that result
// ----------------------------------------------------------------------------
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