+// ----------------------------------------------------------------------------
+// MyFrame::OnOpenURLSamePage
+//
+// Called from file->openurl.
+// Opens and plays a media file from a URL in the current notebook page
+// ----------------------------------------------------------------------------
+void MyFrame::OnOpenURLSamePage(wxCommandEvent& WXUNUSED(event))
+{
+ OpenURL(false);
+}
+
+// ----------------------------------------------------------------------------
+// MyFrame::OnOpenURLNewPage
+//
+// Called from file->openurlinnewpage.
+// Opens and plays a media file from a URL in a new notebook page
+// ----------------------------------------------------------------------------
+void MyFrame::OnOpenURLNewPage(wxCommandEvent& WXUNUSED(event))
+{
+ OpenURL(true);
+}
+
+// ----------------------------------------------------------------------------
+// MyFrame::OpenURL
+//
+// Code to actually open the media file from a URL
+//
+// 1) Create text input dialog and ask the user for an input URL
+// 2) If the user didn't want anything, break out
+// 3) Create a new page if the user wanted one or there isn't a current page
+// 4) Load the media
+// 5) Play the media
+// 6) Reset the text on the status bar
+// 7) Set the slider of the current page to accurately reflect media length
+// ----------------------------------------------------------------------------
+void MyFrame::OpenURL(bool bNewPage)
+{
+ wxString theURL = wxGetTextFromUser(wxT("Enter the URL that has the movie to play"));
+
+ if(!theURL.empty())
+ {
+ if(bNewPage || !m_notebook->GetCurrentPage())
+ m_notebook->AddPage(new MyNotebookPage(m_notebook), theURL, true);
+
+ if( !GetCurrentMediaCtrl()->Load(wxURI(theURL)) )
+ wxMessageBox(wxT("Couldn't load URL!"));
+
+ if( !GetCurrentMediaCtrl()->Play() )
+ wxMessageBox(wxT("Couldn't play movie!"));
+
+ ResetStatus();
+
+ GetCurrentSlider()->SetRange(0,
+ (int)(GetCurrentMediaCtrl()->Length() / 1000));
+ }
+}
+
+// ----------------------------------------------------------------------------
+// MyFrame::OnCloseCurrentPage
+//
+// Called when the user wants to close the current notebook page
+//
+// 1) Get the current page number (wxControl::GetSelection)
+// 2) If there is no current page, break out
+// 3) Delete the current page
+// ----------------------------------------------------------------------------
+void MyFrame::OnCloseCurrentPage(wxCommandEvent& WXUNUSED(event))
+{
+ int sel = m_notebook->GetSelection();
+
+ if (sel != wxNOT_FOUND)
+ {
+ m_notebook->DeletePage(sel);
+ }
+}
+