]>
Commit | Line | Data |
---|---|---|
e8482f24 GL |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: mmboard.cpp | |
3 | // Purpose: Multimedia Library sample | |
4 | // Author: Guilhem Lavaux (created from minimal by J. Smart) | |
5 | // Modified by: | |
6 | // Created: 13/02/2000 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Guilhem Lavaux | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | #ifdef __GNUG__ | |
20 | #pragma implementation "mmboard.cpp" | |
21 | #endif | |
22 | ||
23 | // For compilers that support precompilation, includes "wx/wx.h". | |
24 | #include "wx/wxprec.h" | |
25 | ||
26 | #ifdef __BORLANDC__ | |
27 | #pragma hdrstop | |
28 | #endif | |
29 | ||
30 | // for all others, include the necessary headers (this file is usually all you | |
be5a51fb | 31 | // need because it includes almost all "standard" wxWidgets headers |
e8482f24 GL |
32 | #ifndef WX_PRECOMP |
33 | #include "wx/wx.h" | |
34 | #endif | |
35 | ||
36 | // ---------------------------------------------------------------------------- | |
37 | // ressources | |
38 | // ---------------------------------------------------------------------------- | |
39 | // the application icon | |
618f2efa | 40 | #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__) |
e8482f24 GL |
41 | #include "mondrian.xpm" |
42 | #endif | |
43 | ||
44 | // include multimedia classes | |
45 | #include "wx/mmedia/sndbase.h" | |
46 | #ifdef __WIN32__ | |
47 | #include "wx/mmedia/sndwin.h" | |
48 | #endif | |
49 | #ifdef __UNIX__ | |
50 | #include "wx/mmedia/sndoss.h" | |
51 | #include "wx/mmedia/sndesd.h" | |
52 | #endif | |
53 | ||
54 | #include "wx/statline.h" | |
55 | #include "wx/stattext.h" | |
56 | ||
57 | // include personnal classes | |
58 | #include "mmboard.h" | |
59 | #include "mmbman.h" | |
60 | ||
61 | #include "play.xpm" | |
62 | #include "stop.xpm" | |
63 | #include "eject.xpm" | |
64 | #include "pause.xpm" | |
65 | ||
66 | // ---------------------------------------------------------------------------- | |
67 | // private classes | |
68 | // ---------------------------------------------------------------------------- | |
69 | ||
70 | // Main Multimedia Board frame | |
71 | class MMBoardFrame : public wxFrame | |
72 | { | |
73 | public: | |
74 | // ctor(s) | |
75 | MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSize& size); | |
76 | // dtor | |
77 | ~MMBoardFrame(); | |
dabbc6a5 | 78 | |
e8482f24 GL |
79 | // event handlers |
80 | void OnQuit(wxCommandEvent& event); | |
81 | void OnAbout(wxCommandEvent& event); | |
82 | void OnOpen(wxCommandEvent& event); | |
83 | void OnPlay(wxCommandEvent& event); | |
84 | void OnStop(wxCommandEvent& event); | |
85 | void OnPause(wxCommandEvent& event); | |
86 | void OnEject(wxCommandEvent& event); | |
87 | void OnRefreshInfo(wxEvent& event); | |
88 | void OnSetPosition(wxCommandEvent& event); | |
dabbc6a5 | 89 | |
e8482f24 GL |
90 | void OpenVideoWindow(); |
91 | void CloseVideoWindow(); | |
dabbc6a5 | 92 | |
e8482f24 | 93 | private: |
be5a51fb | 94 | // any class wishing to process wxWidgets events must use this macro |
e8482f24 GL |
95 | DECLARE_EVENT_TABLE() |
96 | ||
97 | private: | |
dabbc6a5 | 98 | void UpdateMMedInfo(); |
e8482f24 | 99 | void UpdateInfoText(); |
dabbc6a5 | 100 | |
e8482f24 | 101 | MMBoardFile *m_opened_file; |
dabbc6a5 | 102 | |
e8482f24 GL |
103 | wxSlider *m_positionSlider; |
104 | wxBitmapButton *m_playButton, *m_pauseButton, *m_stopButton, *m_ejectButton; | |
105 | wxStaticText *m_fileType, *m_infoText; | |
106 | wxWindow *m_video_window; | |
dabbc6a5 | 107 | |
e8482f24 GL |
108 | wxPanel *m_panel; |
109 | wxSizer *m_sizer; | |
dabbc6a5 | 110 | |
e8482f24 GL |
111 | wxTimer *m_refreshTimer; |
112 | }; | |
113 | ||
114 | // ---------------------------------------------------------------------------- | |
115 | // constants | |
116 | // ---------------------------------------------------------------------------- | |
117 | ||
118 | // IDs for the controls and the menu commands | |
119 | enum | |
120 | { | |
121 | // menu items | |
122 | MMBoard_Quit = 1, | |
123 | MMBoard_Open, | |
124 | MMBoard_About, | |
125 | MMBoard_PositionSlider, | |
126 | MMBoard_PlayButton, | |
127 | MMBoard_PauseButton, | |
128 | MMBoard_ResumeButton, | |
129 | MMBoard_StopButton, | |
130 | MMBoard_EjectButton, | |
131 | MMBoard_RefreshInfo | |
132 | }; | |
133 | ||
134 | // ---------------------------------------------------------------------------- | |
be5a51fb | 135 | // event tables and other macros for wxWidgets |
e8482f24 GL |
136 | // ---------------------------------------------------------------------------- |
137 | ||
138 | BEGIN_EVENT_TABLE(MMBoardFrame, wxFrame) | |
139 | EVT_MENU(MMBoard_Quit, MMBoardFrame::OnQuit) | |
140 | EVT_MENU(MMBoard_About, MMBoardFrame::OnAbout) | |
141 | EVT_MENU(MMBoard_Open, MMBoardFrame::OnOpen) | |
142 | EVT_BUTTON(MMBoard_PlayButton, MMBoardFrame::OnPlay) | |
143 | EVT_BUTTON(MMBoard_StopButton, MMBoardFrame::OnStop) | |
144 | EVT_BUTTON(MMBoard_PauseButton, MMBoardFrame::OnPause) | |
dabbc6a5 | 145 | EVT_BUTTON(MMBoard_EjectButton, MMBoardFrame::OnEject) |
e8482f24 GL |
146 | EVT_SLIDER(MMBoard_PositionSlider, MMBoardFrame::OnSetPosition) |
147 | EVT_CUSTOM(wxEVT_TIMER, MMBoard_RefreshInfo, MMBoardFrame::OnRefreshInfo) | |
148 | END_EVENT_TABLE() | |
149 | ||
150 | // --------------------------------------------------------------------------- | |
151 | // Main board application launcher | |
152 | // --------------------------------------------------------------------------- | |
153 | ||
154 | IMPLEMENT_APP(MMBoardApp) | |
155 | ||
156 | // ============================================================================ | |
157 | // implementation | |
158 | // ============================================================================ | |
159 | ||
160 | // ---------------------------------------------------------------------------- | |
161 | // the application class | |
162 | // ---------------------------------------------------------------------------- | |
163 | ||
164 | bool MMBoardApp::OnInit() | |
165 | { | |
166 | // create the main application window | |
2bbf230a | 167 | MMBoardFrame *frame = new MMBoardFrame(_T("Multimedia Board"), |
e8482f24 GL |
168 | wxPoint(50, 50), wxSize(450, 340)); |
169 | ||
170 | // and show it (the frames, unlike simple controls, are not shown when | |
171 | // created initially) | |
dabbc6a5 | 172 | frame->Show(); |
e8482f24 GL |
173 | |
174 | m_caps = TestMultimediaCaps(); | |
175 | ||
176 | if (!m_caps) { | |
2bbf230a | 177 | wxMessageBox(_T("Your system has no multimedia capabilities. We are exiting now."), _T("Major error !"), wxOK | wxICON_ERROR, NULL); |
dabbc6a5 | 178 | return false; |
e8482f24 GL |
179 | } |
180 | ||
181 | wxString msg; | |
2bbf230a | 182 | msg.Printf(_T("Detected : %s%s%s"), (m_caps & MM_SOUND_OSS) ? _T("OSS ") : _T(""), |
dabbc6a5 DS |
183 | (m_caps & MM_SOUND_ESD) ? _T("ESD ") : _T(""), |
184 | (m_caps & MM_SOUND_WIN) ? _T("WIN") : _T("")); | |
e8482f24 | 185 | |
2bbf230a | 186 | wxMessageBox(msg, _T("Good !"), wxOK | wxICON_INFORMATION, NULL); |
e8482f24 GL |
187 | |
188 | // success: wxApp::OnRun() will be called which will enter the main message | |
dabbc6a5 | 189 | // loop and the application will run. If we returned false here, the |
e8482f24 | 190 | // application would exit immediately. |
dabbc6a5 | 191 | return true; |
e8482f24 GL |
192 | } |
193 | ||
194 | wxUint8 MMBoardApp::TestMultimediaCaps() | |
195 | { | |
196 | wxSoundStream *dev; | |
197 | wxUint8 caps; | |
dabbc6a5 | 198 | |
e8482f24 | 199 | caps = 0; |
dabbc6a5 | 200 | |
e8482f24 GL |
201 | #ifdef __UNIX__ |
202 | // We now test the ESD support | |
dabbc6a5 | 203 | |
e8482f24 | 204 | dev = new wxSoundStreamESD(); |
dabbc6a5 | 205 | if (dev->GetError() == wxSOUND_NOERROR) |
e8482f24 GL |
206 | caps |= MM_SOUND_ESD; |
207 | delete dev; | |
dabbc6a5 | 208 | |
e8482f24 | 209 | // We test the OSS (Open Sound System) support. |
c42b1de6 GL |
210 | // WARNING: There is a conflict between ESD and ALSA. We may be interrested |
211 | // in disabling the auto detection of OSS is ESD has been detected. | |
212 | #if 1 | |
213 | if (!(caps & MM_SOUND_ESD)) { | |
214 | #endif | |
215 | ||
e8482f24 GL |
216 | dev = new wxSoundStreamOSS(); |
217 | if (dev->GetError() == wxSOUND_NOERROR) | |
218 | caps |= MM_SOUND_OSS; | |
219 | delete dev; | |
c42b1de6 GL |
220 | #if 1 |
221 | } | |
222 | #endif | |
223 | ||
e8482f24 | 224 | #endif |
dabbc6a5 | 225 | |
e8482f24 GL |
226 | #ifdef __WIN32__ |
227 | // We test the Windows sound support. | |
228 | ||
229 | dev = new wxSoundStreamWin(); | |
5fa399c9 | 230 | if (dev->GetError() == wxSOUND_NOERROR) |
e8482f24 GL |
231 | caps |= MM_SOUND_WIN; |
232 | delete dev; | |
233 | #endif | |
dabbc6a5 | 234 | |
e8482f24 GL |
235 | return caps; |
236 | } | |
237 | ||
238 | // ---------------------------------------------------------------------------- | |
239 | // main frame | |
240 | // ---------------------------------------------------------------------------- | |
241 | ||
242 | // frame constructor | |
243 | MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSize& size) | |
dabbc6a5 | 244 | : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) |
e8482f24 GL |
245 | { |
246 | #ifdef __WXMAC__ | |
247 | // we need this in order to allow the about menu relocation, since ABOUT is | |
248 | // not the default id of the about menu | |
249 | wxApp::s_macAboutMenuItemId = MMBoard_About; | |
250 | #endif | |
251 | ||
252 | // set the frame icon | |
253 | SetIcon(wxICON(mondrian)); | |
254 | ||
255 | // create a menu bar | |
dabbc6a5 | 256 | wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF); |
e8482f24 GL |
257 | |
258 | // the "About" item should be in the help menu | |
259 | wxMenu *helpMenu = new wxMenu; | |
260 | helpMenu->Append(MMBoard_About, wxT("&About...\tCtrl-A"), wxT("Show about dialog")); | |
261 | ||
262 | menuFile->Append(MMBoard_Open, wxT("&Open\tAlt-O"), wxT("Open file")); | |
263 | menuFile->AppendSeparator(); | |
264 | menuFile->Append(MMBoard_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program")); | |
265 | ||
266 | // now append the freshly created menu to the menu bar... | |
267 | wxMenuBar *menuBar = new wxMenuBar(); | |
268 | menuBar->Append(menuFile, wxT("&File")); | |
269 | menuBar->Append(helpMenu, wxT("&Help")); | |
270 | ||
271 | // ... and attach this menu bar to the frame | |
272 | SetMenuBar(menuBar); | |
273 | ||
274 | #if wxUSE_STATUSBAR | |
275 | // create a status bar just for fun (by default with 1 pane only) | |
276 | CreateStatusBar(3); | |
be5a51fb | 277 | SetStatusText(wxT("Welcome to wxWidgets!")); |
e8482f24 GL |
278 | #endif // wxUSE_STATUSBAR |
279 | ||
280 | // Misc variables | |
281 | m_opened_file = NULL; | |
282 | ||
dabbc6a5 | 283 | m_panel = new wxPanel(this, wxID_ANY); |
e8482f24 GL |
284 | |
285 | // Initialize main slider | |
286 | m_positionSlider = new wxSlider( m_panel, MMBoard_PositionSlider, 0, 0, 60, | |
dabbc6a5 DS |
287 | wxDefaultPosition, wxSize(300, -1), |
288 | wxSL_HORIZONTAL | wxSL_AUTOTICKS); | |
e8482f24 | 289 | m_positionSlider->SetPageSize(60); // 60 secs |
dabbc6a5 DS |
290 | m_positionSlider->Disable(); |
291 | ||
e8482f24 | 292 | // Initialize info panel |
dabbc6a5 | 293 | wxPanel *infoPanel = new wxPanel( m_panel, wxID_ANY); |
e8482f24 GL |
294 | infoPanel->SetBackgroundColour(*wxBLACK); |
295 | infoPanel->SetForegroundColour(*wxWHITE); | |
296 | ||
297 | wxBoxSizer *infoSizer = new wxBoxSizer(wxVERTICAL); | |
298 | ||
dabbc6a5 DS |
299 | m_fileType = new wxStaticText(infoPanel, wxID_ANY, wxEmptyString); |
300 | wxStaticLine *line = new wxStaticLine(infoPanel, wxID_ANY); | |
301 | m_infoText = new wxStaticText(infoPanel, wxID_ANY, wxEmptyString); | |
e8482f24 GL |
302 | |
303 | UpdateInfoText(); | |
304 | ||
305 | infoSizer->Add(m_fileType, 0, wxGROW | wxALL, 1); | |
306 | infoSizer->Add(line, 0, wxGROW | wxCENTRE, 20); | |
307 | infoSizer->Add(m_infoText, 0, wxGROW | wxALL, 1); | |
dabbc6a5 | 308 | |
e8482f24 | 309 | infoPanel->SetSizer(infoSizer); |
e8482f24 GL |
310 | |
311 | // Bitmap button panel | |
312 | wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); | |
dabbc6a5 | 313 | |
a977709b JS |
314 | wxBitmap play_bmp(play_back_xpm); |
315 | wxBitmap stop_bmp(stop_back_xpm); | |
316 | wxBitmap eject_bmp(eject_xpm); | |
317 | wxBitmap pause_bmp(pause_xpm); | |
e8482f24 | 318 | |
a977709b | 319 | m_playButton = new wxBitmapButton(m_panel, MMBoard_PlayButton, play_bmp); |
dabbc6a5 | 320 | m_playButton->Disable(); |
a977709b | 321 | m_pauseButton = new wxBitmapButton(m_panel, MMBoard_PauseButton, pause_bmp); |
dabbc6a5 | 322 | m_pauseButton->Disable(); |
a977709b | 323 | m_stopButton = new wxBitmapButton(m_panel, MMBoard_StopButton, stop_bmp); |
dabbc6a5 | 324 | m_stopButton->Disable(); |
a977709b | 325 | m_ejectButton = new wxBitmapButton(m_panel, MMBoard_EjectButton, eject_bmp); |
dabbc6a5 DS |
326 | m_ejectButton->Disable(); |
327 | ||
e8482f24 | 328 | buttonSizer->Add(m_playButton, 0, wxALL, 2); |
dabbc6a5 | 329 | buttonSizer->Add(m_pauseButton, 0, wxALL, 2); |
e8482f24 GL |
330 | buttonSizer->Add(m_stopButton, 0, wxALL, 2); |
331 | buttonSizer->Add(m_ejectButton, 0, wxALL, 2); | |
332 | ||
333 | // Top sizer | |
334 | m_sizer = new wxBoxSizer(wxVERTICAL); | |
dabbc6a5 | 335 | m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0); |
e8482f24 | 336 | m_sizer->Add(m_positionSlider, 0, wxCENTRE | wxGROW | wxALL, 2); |
dabbc6a5 | 337 | m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0); |
e8482f24 | 338 | m_sizer->Add(buttonSizer, 0, wxALL, 0); |
dabbc6a5 | 339 | m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0); |
e8482f24 | 340 | m_sizer->Add(infoPanel, 1, wxCENTRE | wxGROW, 0); |
dabbc6a5 | 341 | |
e8482f24 | 342 | m_panel->SetSizer(m_sizer); |
e8482f24 GL |
343 | m_sizer->Fit(this); |
344 | m_sizer->SetSizeHints(this); | |
345 | ||
346 | // Timer | |
347 | m_refreshTimer = new wxTimer(this, MMBoard_RefreshInfo); | |
348 | ||
349 | // Video window | |
350 | m_video_window = NULL; | |
351 | ||
352 | // Multimedia file | |
353 | m_opened_file = NULL; | |
354 | } | |
355 | ||
356 | MMBoardFrame::~MMBoardFrame() | |
357 | { | |
358 | if (m_opened_file) | |
359 | delete m_opened_file; | |
dabbc6a5 | 360 | |
e8482f24 GL |
361 | delete m_refreshTimer; |
362 | } | |
363 | ||
364 | void MMBoardFrame::OpenVideoWindow() | |
365 | { | |
366 | if (m_video_window) | |
367 | return; | |
368 | ||
dabbc6a5 | 369 | m_video_window = new wxWindow(m_panel, wxID_ANY, wxDefaultPosition, wxSize(200, 200)); |
e8482f24 GL |
370 | m_video_window->SetBackgroundColour(*wxBLACK); |
371 | m_sizer->Prepend(m_video_window, 2, wxGROW | wxSHRINK | wxCENTRE, 1); | |
372 | ||
373 | m_sizer->Fit(this); | |
374 | } | |
375 | ||
376 | void MMBoardFrame::CloseVideoWindow() | |
377 | { | |
378 | if (!m_video_window) | |
379 | return; | |
12a3f227 RL |
380 | |
381 | m_sizer->Detach( m_video_window ); | |
e8482f24 GL |
382 | delete m_video_window; |
383 | m_video_window = NULL; | |
12a3f227 | 384 | |
e8482f24 GL |
385 | m_sizer->Fit(this); |
386 | } | |
387 | ||
388 | // event handlers | |
389 | ||
390 | void MMBoardFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
391 | { | |
dabbc6a5 DS |
392 | // true is to force the frame to close |
393 | Close(true); | |
e8482f24 GL |
394 | } |
395 | ||
396 | void MMBoardFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) | |
397 | { | |
398 | wxString msg; | |
be5a51fb JS |
399 | msg.Printf( wxT("wxWidgets Multimedia board v1.0a, wxMMedia v2.0a:\n") |
400 | wxT("an example of the capabilities of the wxWidgets multimedia classes.\n") | |
dabbc6a5 DS |
401 | wxT("Copyright 1999, 2000, Guilhem Lavaux.\n")); |
402 | ||
2bbf230a | 403 | wxMessageBox(msg, _T("About MMBoard"), wxOK | wxICON_INFORMATION, this); |
e8482f24 GL |
404 | } |
405 | ||
406 | void MMBoardFrame::OnOpen(wxCommandEvent& WXUNUSED(event)) | |
407 | { | |
408 | wxString selected_file; | |
dabbc6a5 | 409 | |
e8482f24 GL |
410 | if (m_opened_file) { |
411 | if (!m_opened_file->IsStopped()) { | |
412 | wxCommandEvent event2; | |
413 | OnStop(event2); | |
414 | } | |
415 | delete m_opened_file; | |
416 | } | |
dabbc6a5 | 417 | |
e8482f24 | 418 | // select a file to be opened |
2bbf230a | 419 | selected_file = wxLoadFileSelector(_T("multimedia"), _T("*"), NULL, this); |
e8482f24 GL |
420 | if (selected_file.IsNull()) |
421 | return; | |
dabbc6a5 | 422 | |
e8482f24 | 423 | m_opened_file = MMBoardManager::Open(selected_file); |
dabbc6a5 | 424 | |
e8482f24 GL |
425 | // Change the range values of the slider. |
426 | MMBoardTime length; | |
dabbc6a5 | 427 | |
e8482f24 GL |
428 | length = m_opened_file->GetLength(); |
429 | m_positionSlider->SetRange(0, length.hours * 3600 + length.minutes * 60 + length.seconds); | |
dabbc6a5 | 430 | |
e8482f24 GL |
431 | // Update misc info |
432 | UpdateMMedInfo(); | |
dabbc6a5 | 433 | |
e8482f24 | 434 | SetStatusText(selected_file, 2); |
dabbc6a5 | 435 | |
e8482f24 GL |
436 | // Update info text |
437 | UpdateInfoText(); | |
dabbc6a5 | 438 | |
e8482f24 | 439 | // Enable a few buttons |
dabbc6a5 DS |
440 | m_playButton->Enable(); |
441 | m_ejectButton->Enable(); | |
442 | m_positionSlider->Enable(); | |
443 | ||
e8482f24 GL |
444 | if (m_opened_file->NeedWindow()) { |
445 | OpenVideoWindow(); | |
446 | m_opened_file->SetWindow(m_video_window); | |
447 | } else | |
448 | CloseVideoWindow(); | |
449 | } | |
450 | ||
451 | void MMBoardFrame::UpdateInfoText() | |
452 | { | |
453 | wxString infotext1, infotext2; | |
dabbc6a5 | 454 | |
e8482f24 GL |
455 | if (m_opened_file) { |
456 | infotext1 = wxT("File type:\n\t"); | |
457 | infotext1 += m_opened_file->GetStringType() + wxT("\n"); | |
dabbc6a5 | 458 | |
e8482f24 GL |
459 | infotext2 = wxT("File informations:\n\n"); |
460 | infotext2 += m_opened_file->GetStringInformation(); | |
461 | } else { | |
462 | infotext1 = wxT("File type: \n\tNo file opened"); | |
463 | infotext2 = wxT("File informations:\nNo information\n\n\n\n\n"); | |
464 | } | |
dabbc6a5 | 465 | |
e8482f24 GL |
466 | m_fileType->SetLabel(infotext1); |
467 | m_infoText->SetLabel(infotext2); | |
468 | } | |
469 | ||
470 | void MMBoardFrame::UpdateMMedInfo() | |
471 | { | |
472 | wxString temp_string; | |
473 | MMBoardTime current, length; | |
dabbc6a5 | 474 | |
e8482f24 GL |
475 | if (m_opened_file) { |
476 | current = m_opened_file->GetPosition(); | |
477 | length = m_opened_file->GetLength(); | |
478 | } else { | |
479 | current.hours = current.minutes = current.seconds = 0; | |
480 | length = current; | |
481 | } | |
482 | ||
483 | // We refresh the status bar | |
484 | temp_string.Printf(wxT("%02d:%02d / %02d:%02d"), current.hours * 60 + current.minutes, | |
485 | current.seconds, length.hours * 60 + length.minutes, length.seconds); | |
486 | SetStatusText(temp_string, 1); | |
dabbc6a5 | 487 | |
e8482f24 GL |
488 | // We set the slider position |
489 | m_positionSlider->SetValue(current.hours * 3600 + current.minutes * 60 + current.seconds); | |
490 | } | |
491 | ||
492 | // ---------------------------------------------------------------------------- | |
493 | // Playing management, refreshers, ... | |
494 | ||
495 | void MMBoardFrame::OnRefreshInfo(wxEvent& WXUNUSED(event)) | |
496 | { | |
497 | UpdateMMedInfo(); | |
dabbc6a5 DS |
498 | |
499 | if (m_opened_file->IsStopped()) | |
500 | { | |
e8482f24 | 501 | m_refreshTimer->Stop(); |
dabbc6a5 DS |
502 | m_playButton->Enable(); |
503 | m_stopButton->Disable(); | |
504 | m_pauseButton->Disable(); | |
e8482f24 GL |
505 | } |
506 | } | |
507 | ||
508 | void MMBoardFrame::OnPlay(wxCommandEvent& WXUNUSED(event)) | |
509 | { | |
dabbc6a5 DS |
510 | m_stopButton->Enable(); |
511 | m_pauseButton->Enable(); | |
512 | m_playButton->Disable(); | |
513 | ||
514 | if (m_opened_file->IsPaused()) | |
515 | { | |
e8482f24 GL |
516 | m_opened_file->Resume(); |
517 | return; | |
518 | } | |
dabbc6a5 DS |
519 | |
520 | m_refreshTimer->Start(1000, false); | |
521 | ||
e8482f24 | 522 | m_opened_file->Play(); |
dabbc6a5 DS |
523 | |
524 | m_stopButton->Enable(); | |
525 | m_pauseButton->Enable(); | |
526 | m_playButton->Disable(); | |
e8482f24 GL |
527 | } |
528 | ||
529 | void MMBoardFrame::OnStop(wxCommandEvent& WXUNUSED(event)) | |
530 | { | |
531 | m_opened_file->Stop(); | |
532 | m_refreshTimer->Stop(); | |
533 | ||
dabbc6a5 DS |
534 | m_stopButton->Disable(); |
535 | m_playButton->Enable(); | |
536 | ||
e8482f24 GL |
537 | UpdateMMedInfo(); |
538 | } | |
539 | ||
540 | void MMBoardFrame::OnPause(wxCommandEvent& WXUNUSED(event)) | |
541 | { | |
542 | m_opened_file->Pause(); | |
dabbc6a5 DS |
543 | |
544 | m_playButton->Enable(); | |
545 | m_pauseButton->Disable(); | |
e8482f24 GL |
546 | } |
547 | ||
548 | void MMBoardFrame::OnEject(wxCommandEvent& WXUNUSED(event)) | |
549 | { | |
550 | m_opened_file->Stop(); | |
551 | ||
552 | delete m_opened_file; | |
553 | m_opened_file = NULL; | |
dabbc6a5 DS |
554 | |
555 | m_playButton->Disable(); | |
556 | m_pauseButton->Disable(); | |
557 | m_stopButton->Disable(); | |
558 | m_ejectButton->Disable(); | |
559 | m_positionSlider->Disable(); | |
e8482f24 GL |
560 | |
561 | UpdateInfoText(); | |
562 | UpdateMMedInfo(); | |
563 | } | |
564 | ||
565 | void MMBoardFrame::OnSetPosition(wxCommandEvent& WXUNUSED(event)) | |
566 | { | |
567 | wxUint32 itime; | |
568 | MMBoardTime btime; | |
dabbc6a5 | 569 | |
e8482f24 GL |
570 | itime = m_positionSlider->GetValue(); |
571 | btime.seconds = itime % 60; | |
572 | btime.minutes = (itime / 60) % 60; | |
573 | btime.hours = itime / 3600; | |
574 | m_opened_file->SetPosition(btime); | |
575 | ||
576 | UpdateMMedInfo(); | |
577 | } | |
578 |