1 /*****************************************************************************
2 * interface.cpp: WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
42 #define NUMIMAGES 9 // Number of buttons in the toolbar
43 #define IMAGEWIDTH 17 // Width of the buttons in the toolbar
44 #define IMAGEHEIGHT 16 // Height of the buttons in the toolbar
45 #define BUTTONWIDTH 0 // Width of the button images in the toolbar
46 #define BUTTONHEIGHT 0 // Height of the button images in the toolbar
47 #define ID_TOOLBAR 2000 // Identifier of the main tool bar
50 #define HELP_SIMPLE _T("Quick file open")
51 #define HELP_ADV _T("Advanced open")
52 #define HELP_FILE _T("Open a file")
53 #define HELP_DISC _T("Open Disc Media")
54 #define HELP_NET _T("Open a network stream")
55 #define HELP_SAT _T("Open a satellite stream")
56 #define HELP_EJECT _T("Eject the DVD/CD")
57 #define HELP_EXIT _T("Exit this program")
59 #define HELP_OTHER _T("Open other types of inputs")
61 #define HELP_PLAYLIST _T("Open the playlist")
62 #define HELP_LOGS _T("Show the program logs")
63 #define HELP_FILEINFO _T("Show information about the file being played")
65 #define HELP_PREFS _T("Go to the preferences menu")
67 #define HELP_ABOUT _T("About this program")
69 #define HELP_STOP _T("Stop")
71 #define HELP_PLAY _T("Play")
72 #define HELP_PAUSE _T("Pause")
73 #define HELP_PLO _T("Playlist")
74 #define HELP_PLP _T("Previous playlist item")
75 #define HELP_PLN _T("Next playlist item")
76 #define HELP_SLOW _T("Play slower")
77 #define HELP_FAST _T("Play faster")
79 // The TBBUTTON structure contains information the toolbar buttons.
80 static TBBUTTON tbButton[] =
82 {0, ID_FILE_QUICKOPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON},
83 {1, ID_FILE_OPENNET, TBSTATE_ENABLED, TBSTYLE_BUTTON},
84 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
85 {2, StopStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
86 {3, PlayStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
87 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
88 {4, ID_VIEW_PLAYLIST, TBSTATE_ENABLED, TBSTYLE_BUTTON},
89 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
90 {5, PrevStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
91 {6, NextStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
92 {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP},
93 {7, SlowStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
94 {8, FastStream_Event, TBSTATE_ENABLED, TBSTYLE_BUTTON},
98 TCHAR * szToolTips[] =
100 HELP_SIMPLE, HELP_NET, HELP_STOP, HELP_PLAY, HELP_PLO, HELP_PLP,
101 HELP_PLN, HELP_SLOW, HELP_FAST
104 /*****************************************************************************
106 *****************************************************************************/
107 Interface::Interface()
108 : hwndMain(0), hwndCB(0), hwndTB(0), hwndSlider(0), hwndLabel(0),
109 hwndVol(0), hwndSB(0),
110 fileinfo(0), messages(0), preferences(0), playlist(0),
111 timer(0), open(0), video(0), b_volume_hold(0)
115 Interface::~Interface()
117 if( timer ) delete timer;
118 if( video ) delete video;
121 BOOL Interface::InitInstance( HINSTANCE hInstance, intf_thread_t *_p_intf )
123 /* Initializations */
125 i_old_playing_status = PAUSE_S;
127 hInst = hInstance; // Store instance handle in our global variable
129 // Register window class
131 wc.style = CS_HREDRAW | CS_VREDRAW ;
132 wc.lpfnWndProc = (WNDPROC)BaseWndProc;
136 wc.hInstance = hInstance;
138 wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
139 wc.lpszMenuName = NULL;
140 wc.lpszClassName = _T("VLC WinCE");
141 if( !RegisterClass( &wc ) ) return FALSE;
143 int i_style = WS_VISIBLE;
146 i_style |= WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
149 // Create main window
151 CreateWindow( _T("VLC WinCE"), _T("VLC media player"), i_style,
152 0, MENU_HEIGHT, CW_USEDEFAULT, CW_USEDEFAULT,
153 NULL, NULL, hInstance, (void *)this );
155 if( !hwndMain ) return FALSE;
157 ShowWindow( hwndMain, TRUE );
158 UpdateWindow( hwndMain );
163 /***********************************************************************
169 ***********************************************************************/
170 HWND Interface::CreateMenuBar( HWND hwnd, HINSTANCE hInst )
172 HMENU menu_file, menu_view;
176 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
177 mbi.cbSize = sizeof(SHMENUBARINFO);
178 mbi.hwndParent = hwnd;
179 mbi.hInstRes = hInst;
180 mbi.nToolBarId = IDR_MENUBAR;
182 if( !SHCreateMenuBar( &mbi ) )
184 MessageBox(hwnd, _T("SHCreateMenuBar Failed"), _T("Error"), MB_OK);
189 tbbi.cbSize = sizeof(tbbi);
190 tbbi.dwMask = TBIF_LPARAM;
192 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_FILE, (LPARAM)&tbbi );
193 menu_file = (HMENU)tbbi.lParam;
194 RemoveMenu( menu_file, 0, MF_BYPOSITION );
195 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIEW, (LPARAM)&tbbi );
196 menu_view = (HMENU)tbbi.lParam;
197 RemoveMenu( menu_view, 0, MF_BYPOSITION );
198 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_SETTINGS, (LPARAM)&tbbi );
199 menu_settings = (HMENU)tbbi.lParam;
200 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_VIDEO, (LPARAM)&tbbi );
201 menu_video = (HMENU)tbbi.lParam;
202 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_AUDIO, (LPARAM)&tbbi );
203 menu_audio = (HMENU)tbbi.lParam;
204 SendMessage( mbi.hwndMB, TB_GETBUTTONINFO, IDM_NAVIGATION, (LPARAM)&tbbi );
205 menu_navigation = (HMENU)tbbi.lParam;
208 menu_file = CreatePopupMenu();
209 menu_view = CreatePopupMenu();
210 menu_settings = CreatePopupMenu();
211 menu_audio = CreatePopupMenu();
212 menu_video = CreatePopupMenu();
213 menu_navigation = CreatePopupMenu();
216 AppendMenu( menu_file, MF_STRING, ID_FILE_QUICKOPEN,
217 _T("Quick &Open File...") );
218 AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
219 AppendMenu( menu_file, MF_STRING, ID_FILE_OPENFILE,
220 _T("Open &File...") );
221 AppendMenu( menu_file, MF_STRING, ID_FILE_OPENNET,
222 _T("Open &Network Stream...") );
223 AppendMenu( menu_file, MF_SEPARATOR, 0, 0 );
224 AppendMenu( menu_file, MF_STRING, ID_FILE_ABOUT,
226 AppendMenu( menu_file, MF_STRING, ID_FILE_EXIT,
229 AppendMenu( menu_view, MF_STRING, ID_VIEW_PLAYLIST,
230 _T("&Playlist...") );
231 AppendMenu( menu_view, MF_STRING, ID_VIEW_MESSAGES,
232 _T("&Messages...") );
233 AppendMenu( menu_view, MF_STRING, ID_VIEW_STREAMINFO,
234 _T("Stream and Media &info...") );
236 AppendMenu( menu_settings, MF_STRING, ID_PREFERENCES,
237 _T("&Preferences...") );
244 HMENU hmenu = CreateMenu();
246 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_file, _T("File") );
247 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_view, _T("View") );
248 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_settings,
250 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_audio, _T("Audio") );
251 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_video, _T("Video") );
252 AppendMenu( hmenu, MF_POPUP|MF_STRING, (UINT)menu_navigation, _T("Nav") );
254 SetMenu( hwnd, hmenu );
260 /***********************************************************************
265 Registers the TOOLBAR control class and creates a toolbar.
266 ***********************************************************************/
267 HWND CreateToolBar( HWND hwnd, HINSTANCE hInst )
273 INITCOMMONCONTROLSEX iccex;
274 iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
275 iccex.dwICC = ICC_BAR_CLASSES;
277 // Registers TOOLBAR control classes from the common control dll
278 InitCommonControlsEx (&iccex);
280 // Create the toolbar control
281 dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS |
282 WS_EX_OVERLAPPEDWINDOW | CCS_NOPARENTALIGN;
284 hwndTB = CreateToolbarEx( hwnd, dwStyle, 0, NUMIMAGES,
285 hInst, IDB_BITMAP1, tbButton, sizeof(tbButton) / sizeof(TBBUTTON),
286 BUTTONWIDTH, BUTTONHEIGHT, IMAGEWIDTH, IMAGEHEIGHT, sizeof(TBBUTTON) );
288 if( !hwndTB ) return NULL;
290 // Add ToolTips to the toolbar.
291 SendMessage( hwndTB, TB_SETTOOLTIPS, (WPARAM)NUMIMAGES,
292 (LPARAM)szToolTips );
294 // Reposition the toolbar.
295 GetClientRect( hwnd, &rect );
296 GetWindowRect( hwndTB, &rectTB );
297 MoveWindow( hwndTB, rect.left, rect.bottom - rect.top - 2*MENU_HEIGHT,
298 rect.right - rect.left, MENU_HEIGHT, TRUE );
303 /***********************************************************************
309 Registers the TRACKBAR_CLASS control class and creates a trackbar.
311 ***********************************************************************/
312 HWND CreateSliderBar( HWND hwnd, HINSTANCE hInst )
317 INITCOMMONCONTROLSEX iccex;
318 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
319 iccex.dwICC = ICC_BAR_CLASSES;
321 // Registers TRACKBAR_CLASS control classes from the common control dll
322 InitCommonControlsEx( &iccex );
324 hwndSlider = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
325 WS_CHILD | WS_VISIBLE | TBS_HORZ | WS_EX_OVERLAPPEDWINDOW |
326 TBS_BOTTOM, //|WS_CLIPSIBLINGS,
327 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
329 if( !hwndSlider ) return NULL;
331 SendMessage( hwndSlider, TBM_SETRANGEMIN, 1, 0 );
332 SendMessage( hwndSlider, TBM_SETRANGEMAX, 1, SLIDER_MAX_POS );
333 SendMessage( hwndSlider, TBM_SETPOS, 1, 0 );
335 // Reposition the trackbar
336 GetClientRect( hwnd, &rect );
337 MoveWindow( hwndSlider, rect.left,
338 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
339 rect.right - rect.left - 40, 30, TRUE );
341 ShowWindow( hwndSlider, SW_HIDE );
346 HWND CreateStaticText( HWND hwnd, HINSTANCE hInst )
351 hwndLabel = CreateWindowEx( 0, _T("STATIC"), _T("label"),
352 WS_CHILD | WS_VISIBLE | SS_CENTER ,
353 0, 0, 0, 0, hwnd, (HMENU)1980, hInst, NULL );
355 // Reposition the trackbar
356 GetClientRect( hwnd, &rect );
358 MoveWindow( hwndLabel, rect.left,
359 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT +30,
360 rect.right - rect.left - 40,
361 SLIDER_HEIGHT - 30, TRUE );
363 ShowWindow( hwndLabel, SW_HIDE );
368 /***********************************************************************
374 Registers the TRACKBAR_CLASS control class and creates a trackbar.
376 ***********************************************************************/
377 HWND CreateVolTrackBar( HWND hwnd, HINSTANCE hInst )
382 INITCOMMONCONTROLSEX iccex;
383 iccex.dwSize = sizeof( INITCOMMONCONTROLSEX );
384 iccex.dwICC = ICC_BAR_CLASSES;
386 // Registers TRACKBAR_CLASS control classes from the common control dll
387 InitCommonControlsEx( &iccex );
389 hwndVol = CreateWindowEx( 0, TRACKBAR_CLASS, NULL,
390 WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_RIGHT | TBS_AUTOTICKS |
391 WS_EX_OVERLAPPEDWINDOW, //|WS_CLIPSIBLINGS,
392 0, 0, 0, 0, hwnd, NULL, hInst, NULL );
394 if( !hwndVol ) return NULL;
396 SendMessage( hwndVol, TBM_SETRANGEMIN, 1, 0 );
397 SendMessage( hwndVol, TBM_SETRANGEMAX, 1, 200 );
398 SendMessage( hwndVol, TBM_SETPOS, 1, 100 );
399 SendMessage( hwndVol, TBM_SETTICFREQ, 50, 0 );
401 // Reposition the trackbar
402 GetClientRect( hwnd, &rect );
403 MoveWindow( hwndVol, rect.right - rect.left - 40,
404 rect.bottom - rect.top - 2*(MENU_HEIGHT-1) - SLIDER_HEIGHT,
405 40, SLIDER_HEIGHT, TRUE );
407 ShowWindow( hwndVol, SW_HIDE );
412 /***********************************************************************
418 Registers the StatusBar control class and creates a Statusbar.
420 ***********************************************************************/
421 HWND CreateStatusBar( HWND hwnd, HINSTANCE hInst )
427 INITCOMMONCONTROLSEX iccex;
428 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
429 iccex.dwICC = ICC_BAR_CLASSES;
431 // Registers Statusbar control classes from the common control dll
432 InitCommonControlsEx( &iccex );
434 // Create the statusbar control
435 dwStyle = WS_VISIBLE | WS_CHILD | TBSTYLE_TOOLTIPS | CCS_NOPARENTALIGN;
437 hwndSB = CreateWindowEx( 0, STATUSCLASSNAME, NULL,
438 WS_CHILD | WS_VISIBLE | TBS_VERT | TBS_BOTTOM |
439 TBS_RIGHT |WS_CLIPSIBLINGS,
440 0, 0, CW_USEDEFAULT, 50, hwnd, NULL, hInst, 0 );
442 if (!hwndSB ) return NULL;
444 // Get the coordinates of the parent window's client area.
445 GetClientRect( hwnd, &rect );
447 // allocate memory for the panes of status bar
449 int *indicators = new int[nopanes];
451 // set width for the panes
452 indicators[0] = 3 * ( rect.right - rect.left ) / 4;
453 indicators[1] = rect.right - rect.left;
455 // call functions to set style
456 SendMessage( hwndSB, SB_SETPARTS, (WPARAM)nopanes, (LPARAM)indicators );
461 /***********************************************************************
466 Creates a Dialog Box.
467 ***********************************************************************/
468 int CBaseWindow::CreateDialogBox( HWND hwnd, CBaseWindow *p_obj )
470 uint8_t p_buffer[sizeof(DLGTEMPLATE) + sizeof(WORD) * 4];
471 DLGTEMPLATE *p_dlg_template = (DLGTEMPLATE *)p_buffer;
472 memset( p_dlg_template, 0, sizeof(DLGTEMPLATE) + sizeof(WORD) * 4 );
474 // these values are arbitrary, they won't be used normally anyhow
475 p_dlg_template->x = 0; p_dlg_template->y = 0;
476 p_dlg_template->cx = 300; p_dlg_template->cy = 300;
477 p_dlg_template->style =
478 DS_MODALFRAME|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX;
480 return DialogBoxIndirectParam( GetModuleHandle(0), p_dlg_template, hwnd,
481 (DLGPROC)p_obj->BaseWndProc, (LPARAM)p_obj );
484 /***********************************************************************
489 Processes messages sent to the main window.
490 ***********************************************************************/
491 LRESULT CALLBACK CBaseWindow::BaseWndProc( HWND hwnd, UINT msg, WPARAM wParam,
496 // check to see if a copy of the 'this' pointer needs to be saved
497 if( msg == WM_CREATE )
499 p_obj = (CBaseWindow *)(((LPCREATESTRUCT)lParam)->lpCreateParams);
500 SetWindowLong( hwnd, GWL_USERDATA,
501 (LONG)((LPCREATESTRUCT)lParam)->lpCreateParams );
506 if( msg == WM_INITDIALOG )
508 p_obj = (CBaseWindow *)lParam;
509 SetWindowLong( hwnd, GWL_USERDATA, lParam );
513 // Retrieve the pointer
514 p_obj = (CBaseWindow *)GetWindowLong( hwnd, GWL_USERDATA );
516 if( !p_obj ) return DefWindowProc( hwnd, msg, wParam, lParam );
518 // Filter message through child classes
519 return p_obj->WndProc( hwnd, msg, wParam, lParam );
522 /***********************************************************************
527 Processes messages sent to the main window.
528 ***********************************************************************/
529 LRESULT Interface::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
534 hwndCB = CreateMenuBar( hwnd, hInst );
535 hwndTB = CreateToolBar( hwnd, hInst );
536 hwndSlider = CreateSliderBar( hwnd, hInst );
537 hwndLabel = CreateStaticText( hwnd, hInst );
538 hwndVol = CreateVolTrackBar( hwnd, hInst );
540 hwndSB = CreateStatusBar( hwnd, hInst );
544 if( config_GetInt( p_intf, "wince-embed" ) )
545 video = CreateVideoWindow( p_intf, hwnd );
547 timer = new Timer( p_intf, hwnd, this );
549 // Hide the SIP button (WINCE only)
550 SetForegroundWindow( hwnd );
551 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
555 switch( GET_WM_COMMAND_ID(wp,lp) )
557 case ID_FILE_QUICKOPEN:
561 case ID_FILE_OPENFILE:
562 open = new OpenDialog( p_intf, hInst, FILE_ACCESS,
563 ID_FILE_OPENFILE, OPEN_NORMAL );
564 CreateDialogBox( hwnd, open );
568 case ID_FILE_OPENNET:
569 open = new OpenDialog( p_intf, hInst, NET_ACCESS, ID_FILE_OPENNET,
571 CreateDialogBox( hwnd, open );
575 case PlayStream_Event:
579 case StopStream_Event:
583 case PrevStream_Event:
587 case NextStream_Event:
591 case SlowStream_Event:
595 case FastStream_Event:
601 string about = (string)"VLC media player " PACKAGE_VERSION +
602 _("\n(WinCE interface)\n\n") +
603 _("(c) 1996-2005 - the VideoLAN Team\n\n") +
604 _("The VideoLAN team <videolan@videolan.org>\n"
605 "http://www.videolan.org/\n\n");
607 MessageBox( hwnd, _FROMMB(about.c_str()),
608 _T("About VLC media player"), MB_OK );
613 SendMessage( hwnd, WM_CLOSE, 0, 0 );
616 case ID_VIEW_STREAMINFO:
617 fileinfo = new FileInfo( p_intf, hInst );
618 CreateDialogBox( hwnd, fileinfo );
622 case ID_VIEW_MESSAGES:
623 messages = new Messages( p_intf, hInst );
624 CreateDialogBox( hwnd, messages );
628 case ID_VIEW_PLAYLIST:
629 playlist = new Playlist( p_intf, hInst );
630 CreateDialogBox( hwnd, playlist );
635 preferences = new PrefsDialog( p_intf, hInst );
636 CreateDialogBox( hwnd, preferences );
641 OnMenuEvent( p_intf, GET_WM_COMMAND_ID(wp,lp) );
642 // we should test if it is a menu command
650 case WM_CTLCOLORSTATIC:
651 if( ( (HWND)lp == hwndSlider ) || ( (HWND)lp == hwndVol ) )
653 return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
655 if( (HWND)lp == hwndLabel )
657 SetBkColor( (HDC)wp, RGB (192, 192, 192) );
658 return( (LRESULT)::GetSysColorBrush(COLOR_3DFACE) );
663 if( (HWND)lp == hwndSlider ) OnSliderUpdate( wp );
667 if( (HWND)lp == hwndVol ) OnChange( wp );
670 case WM_INITMENUPOPUP:
671 if( (HMENU)wp == menu_settings )
672 RefreshSettingsMenu( p_intf, menu_settings );
673 if( (HMENU)wp == menu_audio )
674 RefreshAudioMenu( p_intf, menu_audio );
675 if( (HMENU)wp == menu_video )
676 RefreshVideoMenu( p_intf, menu_video );
677 if( (HMENU)wp == menu_navigation )
678 RefreshNavigMenu( p_intf, menu_navigation );
681 case WM_ENTERMENULOOP:
683 if( video && video->hWnd )
684 SendMessage( video->hWnd, WM_KILLFOCUS, 0, 0 );
687 case WM_EXITMENULOOP:
689 if( video && video->hWnd )
690 SendMessage( video->hWnd, WM_SETFOCUS, 0, 0 );
696 shrg.cbSize = sizeof( shrg );
697 shrg.hwndClient = hwnd;
698 shrg.ptDown.x = LOWORD(lp);
699 shrg.ptDown.y = HIWORD(lp);
700 shrg.dwFlags = SHRG_RETURNCMD ;
702 if( SHRecognizeGesture( &shrg ) == GN_CONTEXTMENU )
703 PopupMenu( p_intf, hwnd, shrg.ptDown );
710 point.x = LOWORD(lp);
711 point.y = HIWORD(lp);
712 PopupMenu( p_intf, hwnd, point );
717 MessageBox (hwnd, _T("Help"), _T("Help"), MB_OK);
721 if( hwndCB ) DestroyWindow( hwndCB );
722 DestroyWindow( hwnd );
726 PostQuitMessage( 0 );
730 return DefWindowProc( hwnd, msg, wp, lp );
733 void Interface::OnOpenFileSimple( void )
736 TCHAR DateiName[80+1] = _T("\0");
737 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
739 playlist_t *p_playlist = (playlist_t *)
740 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
741 if( p_playlist == NULL ) return;
743 memset( &ofn, 0, sizeof(OPENFILENAME) );
744 ofn.lStructSize = sizeof(OPENFILENAME);
745 ofn.hwndOwner = NULL;
746 ofn.hInstance = hInst;
747 ofn.lpstrFilter = szFilter;
748 ofn.lpstrCustomFilter = NULL;
749 ofn.nMaxCustFilter = 0;
750 ofn.nFilterIndex = 1;
751 ofn.lpstrFile = (LPTSTR)DateiName;
753 ofn.lpstrFileTitle = NULL;
754 ofn.nMaxFileTitle = 40;
755 ofn.lpstrInitialDir = NULL;
756 ofn.lpstrTitle = _T("Quick Open File");
759 ofn.nFileExtension = 0;
760 ofn.lpstrDefExt = NULL;
763 ofn.lpTemplateName = NULL;
765 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
767 if( GetOpenFile( &ofn ) )
769 char *psz_filename = _TOMB(ofn.lpstrFile);
770 playlist_Add( p_playlist, psz_filename, psz_filename,
771 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
774 vlc_object_release( p_playlist );
777 void Interface::OnPlayStream( void )
779 playlist_t *p_playlist = (playlist_t *)
780 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
781 if( p_playlist == NULL ) return;
783 if( p_playlist->i_size && p_playlist->i_enabled )
787 input_thread_t *p_input = (input_thread_t *)
788 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
790 if( p_input == NULL )
792 /* No stream was playing, start one */
793 playlist_Play( p_playlist );
794 TogglePlayButton( PLAYING_S );
795 vlc_object_release( p_playlist );
799 var_Get( p_input, "state", &state );
801 if( state.i_int != PAUSE_S )
803 /* A stream is being played, pause it */
804 state.i_int = PAUSE_S;
808 /* Stream is paused, resume it */
809 state.i_int = PLAYING_S;
811 var_Set( p_input, "state", state );
813 TogglePlayButton( state.i_int );
814 vlc_object_release( p_input );
815 vlc_object_release( p_playlist );
819 /* If the playlist is empty, open a file requester instead */
820 vlc_object_release( p_playlist );
825 void Interface::TogglePlayButton( int i_playing_status )
827 TBREPLACEBITMAP tbrb;
828 tbrb.hInstOld = tbrb.hInstNew = (HINSTANCE) hInst;
829 tbrb.nButtons = NUMIMAGES;
831 if( i_playing_status == i_old_playing_status ) return;
833 if( i_playing_status == PLAYING_S )
835 tbrb.nIDOld = IDB_BITMAP2;
836 tbrb.nIDNew = IDB_BITMAP1;
838 SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
839 (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
843 tbrb.nIDOld = IDB_BITMAP1;
844 tbrb.nIDNew = IDB_BITMAP2;
846 SendMessage( hwndTB, TB_REPLACEBITMAP, (WPARAM)0,
847 (LPARAM)(LPTBREPLACEBITMAP)&tbrb );
850 UpdateWindow( hwndTB );
852 i_old_playing_status = i_playing_status;
855 void Interface::OnVideoOnTop( void )
859 vout_thread_t *p_vout = (vout_thread_t *)
860 vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
862 if( p_vout == NULL ) return;
864 if( var_Get( (vlc_object_t *)p_vout, "video-on-top", &val ) < 0 )
867 val.b_bool = !val.b_bool;
868 var_Set( (vlc_object_t *)p_vout, "video-on-top", val );
870 vlc_object_release( (vlc_object_t *)p_vout );
873 void Interface::OnSliderUpdate( int wp )
875 vlc_mutex_lock( &p_intf->change_lock );
876 input_thread_t *p_input = p_intf->p_sys->p_input;
878 int dwPos = SendMessage( hwndSlider, TBM_GETPOS, 0, 0 );
880 if( (int)LOWORD(wp) == SB_THUMBPOSITION ||
881 (int)LOWORD(wp) == SB_ENDSCROLL )
883 if( p_intf->p_sys->i_slider_pos != dwPos && p_input )
886 pos.f_float = (float)dwPos / (float)SLIDER_MAX_POS;
887 var_Set( p_input, "position", pos );
890 p_intf->p_sys->b_slider_free = VLC_TRUE;
894 p_intf->p_sys->b_slider_free = VLC_FALSE;
898 /* Update stream date */
899 char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
902 i_seconds = var_GetTime( p_input, "length" ) / I64C(1000000 );
903 secstotimestr( psz_total, i_seconds );
905 i_seconds = var_GetTime( p_input, "time" ) / I64C(1000000 );
906 secstotimestr( psz_time, i_seconds );
908 SendMessage( hwndLabel, WM_SETTEXT, (WPARAM)1,
909 (LPARAM)_FROMMB(psz_time) );
913 vlc_mutex_unlock( &p_intf->change_lock );
916 void Interface::OnChange( int wp )
918 DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
920 if( LOWORD(wp) == SB_THUMBPOSITION || LOWORD(wp) == SB_ENDSCROLL )
922 VolumeChange( 200 - (int)dwPos );
923 b_volume_hold = VLC_FALSE;
927 b_volume_hold = VLC_TRUE;
931 void Interface::VolumeChange( int i_volume )
933 aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 / 2 );
936 void Interface::VolumeUpdate()
938 audio_volume_t i_volume;
940 if( b_volume_hold ) return;
942 aout_VolumeGet( p_intf, &i_volume );
944 int i_volume_ctrl = 200 - i_volume * 200 * 2 / AOUT_VOLUME_MAX;
946 DWORD dwPos = SendMessage( hwndVol, TBM_GETPOS, 0, 0 );
947 if( i_volume_ctrl == (int)dwPos ) return;
949 SendMessage( hwndVol, TBM_SETPOS, 1, i_volume_ctrl );
952 void Interface::OnStopStream( void )
954 playlist_t * p_playlist = (playlist_t *)
955 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
956 if( p_playlist == NULL ) return;
958 playlist_Stop( p_playlist );
959 TogglePlayButton( PAUSE_S );
960 vlc_object_release( p_playlist );
963 void Interface::OnPrevStream( void )
965 playlist_t * p_playlist = (playlist_t *)
966 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
967 if( p_playlist == NULL ) return;
969 playlist_Prev( p_playlist );
970 vlc_object_release( p_playlist );
973 void Interface::OnNextStream( void )
975 playlist_t * p_playlist = (playlist_t *)
976 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
977 if( p_playlist == NULL ) return;
979 playlist_Next( p_playlist );
980 vlc_object_release( p_playlist );
983 void Interface::OnSlowStream( void )
985 input_thread_t *p_input = (input_thread_t *)
986 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
988 if( p_input == NULL ) return;
990 vlc_value_t val; val.b_bool = VLC_TRUE;
991 var_Set( p_input, "rate-slower", val );
992 vlc_object_release( p_input );
995 void Interface::OnFastStream( void )
997 input_thread_t *p_input = (input_thread_t *)
998 vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
1000 if( p_input == NULL ) return;
1002 vlc_value_t val; val.b_bool = VLC_TRUE;
1003 var_Set( p_input, "rate-faster", val );
1004 vlc_object_release( p_input );
1007 void Interface::Update()