+
+}
+
+
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// MyNotebookPage
+//
+// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+// ----------------------------------------------------------------------------
+// MyNotebookPage Constructor
+//
+// Creates a media control and slider and adds it to this panel,
+// along with some sizers for positioning
+// ----------------------------------------------------------------------------
+
+MyNotebookPage::MyNotebookPage(wxNotebook* theBook) :
+ wxPanel(theBook, wxID_ANY), m_nLoops(0), m_bLoop(false)
+{
+ //
+ // Create and attach the first/main sizer
+ //
+ wxBoxSizer* vertsizer = new wxBoxSizer(wxVERTICAL);
+ this->SetSizer(vertsizer);
+ this->SetAutoLayout(true);
+
+ //
+ // Create our media control
+ //
+ m_mediactrl = new wxMediaCtrl();
+
+ // Make sure creation was successful
+ bool bOK = m_mediactrl->Create(this, wxID_MEDIACTRL);
+ wxASSERT_MSG(bOK, wxT("Could not create media control!"));
+
+ vertsizer->Add(m_mediactrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+ //
+ // Create our slider
+ //
+ m_slider = new wxSlider(this, wxID_SLIDER, 0, //init
+ 0, //start
+ 0, //end
+ wxDefaultPosition, wxDefaultSize,
+ wxSL_HORIZONTAL );
+ vertsizer->Add(m_slider, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);
+
+
+ //
+ // Create the second sizer which will position things
+ // vertically -
+ //
+ // -------Menu----------
+ // [m_mediactrl]
+ //
+ // [m_slider]
+ //
+ wxBoxSizer* horzsizer = new wxBoxSizer(wxHORIZONTAL);
+ vertsizer->Add(horzsizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+ //
+ // Slider events
+ //
+ this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyNotebookPage::OnSeek);
+
+ //
+ // Media Control events
+ //
+ this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_FINISHED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxMediaEventFunction) &MyNotebookPage::OnMediaFinished);
+}
+
+// ----------------------------------------------------------------------------
+// MyNotebook::OnSeek
+//
+// Called from file->seek.
+// Called when the user moves the slider -
+// seeks to a position within the media
+// ----------------------------------------------------------------------------
+void MyNotebookPage::OnSeek(wxCommandEvent& WXUNUSED(event))
+{
+ if( m_mediactrl->Seek(
+ m_slider->GetValue() * 1000
+ ) == wxInvalidOffset )
+ wxMessageBox(wxT("Couldn't seek in movie!"));
+}
+
+// ----------------------------------------------------------------------------
+// OnMediaFinished
+//
+// Called when the media stops playing.
+// Here we loop it if the user wants to (has been selected from file menu)
+// ----------------------------------------------------------------------------
+void MyNotebookPage::OnMediaFinished(wxMediaEvent& WXUNUSED(event))
+{
+ if(m_bLoop)
+ {
+ if ( !m_mediactrl->Play() )
+ wxMessageBox(wxT("Couldn't loop movie!"));
+ else
+ ++m_nLoops;
+ }