// Headers
// ----------------------------------------------------------------------------
-#include "wx/mediactrl.h" //for wxMediaCtrl
-#include "wx/filedlg.h" //for opening files from OpenFile
-#include "wx/slider.h" //for a slider for seeking within media
-#include "wx/sizer.h" //for positioning controls/wxBoxSizer
-#include "wx/timer.h" //timer for updating status bar
-#include "wx/textdlg.h" //for getting user text from OpenURL/Debug
-#include "wx/notebook.h" //for wxNotebook and putting movies in pages
-#include "wx/cmdline.h" //for wxCmdLineParser (optional)
-#include "wx/listctrl.h" //for wxListCtrl
-#include "wx/dnd.h" //drag and drop for the playlist
-#include "wx/filename.h" //For wxFileName::GetName()
-#include "wx/config.h" //for native wxConfig
+#include "wx/mediactrl.h" // for wxMediaCtrl
+#include "wx/filedlg.h" // for opening files from OpenFile
+#include "wx/slider.h" // for a slider for seeking within media
+#include "wx/sizer.h" // for positioning controls/wxBoxSizer
+#include "wx/timer.h" // timer for updating status bar
+#include "wx/textdlg.h" // for getting user text from OpenURL/Debug
+#include "wx/notebook.h" // for wxNotebook and putting movies in pages
+#include "wx/cmdline.h" // for wxCmdLineParser (optional)
+#include "wx/listctrl.h" // for wxListCtrl
+#include "wx/dnd.h" // drag and drop for the playlist
+#include "wx/filename.h" // For wxFileName::GetName()
+#include "wx/config.h" // for native wxConfig
#ifndef __WXMSW__
#include "../sample.xpm"
void DoOpenFile(const wxString& path, bool bNewPage);
void DoPlayFile(const wxString& path);
- class wxMediaPlayerTimer* m_timer; //Timer to write info to status bar
- wxNotebook* m_notebook; //Notebook containing our pages
+ class wxMediaPlayerTimer* m_timer; // Timer to write info to status bar
+ wxNotebook* m_notebook; // Notebook containing our pages
// Maybe I should use more accessors, but for simplicity
// I'll allow the other classes access to our members
void OnMediaFinished(wxMediaEvent& event);
public:
- bool IsBeingDragged(); //accessor for m_bIsBeingDragged
+ bool IsBeingDragged(); // accessor for m_bIsBeingDragged
- //make wxMediaPlayerFrame able to access the private members
+ // make wxMediaPlayerFrame able to access the private members
friend class wxMediaPlayerFrame;
- int m_nLastFileId; //List ID of played file in listctrl
- wxString m_szFile; //Name of currently playing file/location
-
- wxMediaCtrl* m_mediactrl; //Our media control
- class wxMediaPlayerListCtrl* m_playlist; //Our playlist
- wxSlider* m_slider; //The slider below our media control
- wxSlider* m_pbSlider; //Lower-left slider for adjusting speed
- wxSlider* m_volSlider; //Lower-right slider for adjusting volume
- int m_nLoops; //Number of times media has looped
- bool m_bLoop; //Whether we are looping or not
- bool m_bIsBeingDragged; //Whether the user is dragging the scroll bar
- wxMediaPlayerFrame* m_parentFrame; //Main wxFrame of our sample
- wxButton* m_prevButton; //Go to previous file button
- wxButton* m_playButton; //Play/pause file button
- wxButton* m_stopButton; //Stop playing file button
- wxButton* m_nextButton; //Next file button
- wxButton* m_vdButton; //Volume down button
- wxButton* m_vuButton; //Volume up button
- wxGauge* m_gauge; //Gauge to keep in line with slider
+ int m_nLastFileId; // List ID of played file in listctrl
+ wxString m_szFile; // Name of currently playing file/location
+
+ wxMediaCtrl* m_mediactrl; // Our media control
+ class wxMediaPlayerListCtrl* m_playlist; // Our playlist
+ wxSlider* m_slider; // The slider below our media control
+ wxSlider* m_pbSlider; // Lower-left slider for adjusting speed
+ wxSlider* m_volSlider; // Lower-right slider for adjusting volume
+ int m_nLoops; // Number of times media has looped
+ bool m_bLoop; // Whether we are looping or not
+ bool m_bIsBeingDragged; // Whether the user is dragging the scroll bar
+ wxMediaPlayerFrame* m_parentFrame; // Main wxFrame of our sample
+ wxButton* m_prevButton; // Go to previous file button
+ wxButton* m_playButton; // Play/pause file button
+ wxButton* m_stopButton; // Stop playing file button
+ wxButton* m_nextButton; // Next file button
+ wxButton* m_vdButton; // Volume down button
+ wxButton* m_vuButton; // Volume up button
+ wxGauge* m_gauge; // Gauge to keep in line with slider
};
// ----------------------------------------------------------------------------
class wxMediaPlayerTimer : public wxTimer
{
public:
- //Ctor
+ // Ctor
wxMediaPlayerTimer(wxMediaPlayerFrame* frame) {m_frame = frame;}
- //Called each time the timer's timeout expires
+ // Called each time the timer's timeout expires
void Notify();
- wxMediaPlayerFrame* m_frame; //The wxMediaPlayerFrame
+ wxMediaPlayerFrame* m_frame; // The wxMediaPlayerFrame
};
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxPlayListDropTarget
//
-// Drop target for playlist (i.e. user drags a file from explorer unto
-// playlist it adds the file)
+// Drop target for playlist (i.e. allows users to drag a file from explorer into
+// the playlist to add that file)
// ----------------------------------------------------------------------------
#if wxUSE_DRAG_AND_DROP
class wxPlayListDropTarget : public wxFileDropTarget
cmdLineDesc[1].kind = wxCMD_LINE_NONE;
- //gets the passed media files from cmd line
+ // gets the passed media files from cmd line
wxCmdLineParser parser (cmdLineDesc, argc, argv);
// get filenames from the commandline
void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
{
- //Called when a user drags a file over our app
+ // Called when a user drags a file over our app
m_frame->DoOpenFile(fileName, true /* new page */);
}
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnClose(wxCloseEvent& event)
{
- event.Skip(); //really close the frame
+ event.Skip(); // really close the frame
}
// ----------------------------------------------------------------------------
wxString msg;
msg.Printf( wxT("This is a test of wxMediaCtrl.\n\n")
- wxT("Intructions:\n")
+ wxT("Instructions:\n")
wxT("The top slider shows the current the current position, ")
wxT("which you can change by dragging and releasing it.\n")
wxT("The gauge (progress bar) shows the progress in ")
wxT("downloading data of the current file - it may always be ")
- wxT("Empty due to lack of support from the current backend.\n")
+ wxT("empty due to lack of support from the current backend.\n")
wxT("The lower-left slider controls the volume and the lower-")
wxT("right slider controls the playback rate/speed of the ")
wxMEDIACTRLPLAYERCONTROLS_DEFAULT :
wxMEDIACTRLPLAYERCONTROLS_NONE) )
{
- //error - uncheck and warn user
+ // error - uncheck and warn user
wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE);
wxASSERT(pSIItem);
pSIItem->Check(!event.IsChecked());
{
wxString sBackend = wxGetTextFromUser(wxT("Enter backend to use"));
- if(sBackend.empty() == false) //could have been cancelled by the user
+ if(sBackend.empty() == false) // could have been cancelled by the user
{
int sel = m_notebook->GetSelection();
wxT("Enter the URL that has the movie to play")
);
- if(sUrl.empty() == false) //could have been cancelled by user
+ if(sUrl.empty() == false) // could have been cancelled by user
{
DoOpenFile(sUrl, bNewPage);
}
wxLIST_NEXT_ALL,
wxLIST_STATE_DONTCARE)) == -1)
{
- //no items in list
+ // no items in list
wxMessageBox(wxT("No items in playlist!"));
}
else
{
wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
- //delete all selected items
+ // delete all selected items
while(true)
{
wxInt32 nSelectedItem = currentpage->m_playlist->GetNextItem(
}
}
- //Could be wxGetTextFromUser or something else important
+ // Could be wxGetTextFromUser or something else important
if(event.GetEventObject() != this)
event.Skip();
}
if (nLastSelectedItem == -1)
{
- //nothing selected, default to the file before the currently playing one
+ // nothing selected, default to the file before the currently playing one
if(currentpage->m_nLastFileId == 0)
nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1;
else
nLastSelectedItem -= 1;
if(nLastSelectedItem == currentpage->m_nLastFileId)
- return; //already playing... nothing to do
+ return; // already playing... nothing to do
wxListItem listitem;
listitem.SetId(nLastSelectedItem);
nLastSelectedItem += 1;
if(nLastSelectedItem == currentpage->m_nLastFileId)
- return; //already playing... nothing to do
+ return; // already playing... nothing to do
wxListItem listitem;
listitem.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA);
// Make sure creation was successful
bool bOK = m_mediactrl->Create(this, wxID_MEDIACTRL, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0,
-//you could specify a macrod backend here like
+// you could specify a macro backend here like
// wxMEDIABACKEND_WMP10);
// wxT("wxPDFMediaBackend"));
szBackend);
-//you could change the cursor here like
+// you could change the cursor here like
// m_mediactrl->SetCursor(wxCURSOR_BLANK);
-//note that this may not effect it if SetPlayerControls
-//is set to something else than wxMEDIACTRLPLAYERCONTROLS_NONE
+// note that this may not effect it if SetPlayerControls
+// is set to something else than wxMEDIACTRLPLAYERCONTROLS_NONE
wxASSERT_MSG(bOK, wxT("Could not create media control!"));
wxUnusedVar(bOK);
m_playlist = new wxMediaPlayerListCtrl();
m_playlist->Create(this, wxID_LISTCTRL, wxDefaultPosition,
wxDefaultSize,
- wxLC_REPORT //wxLC_LIST
+ wxLC_REPORT // wxLC_LIST
| wxSUNKEN_BORDER);
// Set the background of our listctrl to white
m_vuButton = new wxButton();
m_prevButton->Create(this, wxID_BUTTONPREV, wxT("|<"));
+ m_prevButton->SetToolTip("Previous");
m_playButton->Create(this, wxID_BUTTONPLAY, wxT(">"));
+ m_playButton->SetToolTip("Play");
m_stopButton->Create(this, wxID_BUTTONSTOP, wxT("[]"));
+ m_stopButton->SetToolTip("Stop");
m_nextButton->Create(this, wxID_BUTTONNEXT, wxT(">|"));
+ m_nextButton->SetToolTip("Next");
m_vdButton->Create(this, wxID_BUTTONVD, wxT("(("));
+ m_vdButton->SetToolTip("Volume down");
m_vuButton->Create(this, wxID_BUTTONVU, wxT("))"));
+ m_vuButton->SetToolTip("Volume up");
+
vertsizer->Add(m_prevButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
vertsizer->Add(m_playButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
vertsizer->Add(m_stopButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
//
// Create our slider
//
- m_slider = new wxSlider(this, wxID_SLIDER, 0, //init
- 0, //start
- 0, //end
+ m_slider = new wxSlider(this, wxID_SLIDER, 0, // init
+ 0, // start
+ 0, // end
wxDefaultPosition, wxDefaultSize,
wxSL_HORIZONTAL );
sizer->Add(m_slider, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);