00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <stdlib.h>
00029 #include <string.h>
00030 #include <stdio.h>
00031 #include <vlc/vlc.h>
00032 #include <vlc/aout.h>
00033 #include <vlc/intf.h>
00034
00035 #include "wince.h"
00036
00037 #include <commctrl.h>
00038
00039
00040 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
00041 vlc_value_t old_val, vlc_value_t new_val, void * );
00042
00043
00044
00045
00046 Timer::Timer( intf_thread_t *_p_intf, HWND hwnd, Interface *_p_main_interface)
00047 {
00048 p_intf = _p_intf;
00049 p_main_interface = _p_main_interface;
00050 i_old_playing_status = PAUSE_S;
00051 i_old_rate = INPUT_RATE_DEFAULT;
00052
00053
00054 playlist_t *p_playlist =
00055 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00056 FIND_ANYWHERE );
00057 if( p_playlist != NULL )
00058 {
00059 var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
00060 vlc_object_release( p_playlist );
00061 }
00062
00063 SetTimer( hwnd, 1, 200 , NULL );
00064 }
00065
00066 Timer::~Timer()
00067 {
00068
00069 playlist_t *p_playlist =
00070 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00071 FIND_ANYWHERE );
00072 if( p_playlist != NULL )
00073 {
00074 var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
00075 vlc_object_release( p_playlist );
00076 }
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 void Timer::Notify( void )
00090 {
00091 vlc_value_t val;
00092 char *shortname;
00093
00094 vlc_mutex_lock( &p_intf->change_lock );
00095
00096
00097 if( p_intf->p_sys->p_input == NULL )
00098 {
00099 p_intf->p_sys->p_input =
00100 (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
00101 FIND_ANYWHERE );
00102
00103
00104 if( p_intf->p_sys->p_input )
00105 {
00106 ShowWindow( p_main_interface->hwndSlider, SW_SHOW );
00107 ShowWindow( p_main_interface->hwndLabel, SW_SHOW );
00108 ShowWindow( p_main_interface->hwndVol, SW_SHOW );
00109
00110
00111 shortname = strrchr( p_intf->p_sys->p_input->input.p_item->psz_name, '\\' );
00112 if (! shortname)
00113 shortname = p_intf->p_sys->p_input->input.p_item->psz_name;
00114 else shortname++;
00115
00116 SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
00117 (WPARAM) 0, (LPARAM)_FROMMB(shortname) );
00118
00119 p_main_interface->TogglePlayButton( PLAYING_S );
00120 i_old_playing_status = PLAYING_S;
00121 }
00122 }
00123 else if( p_intf->p_sys->p_input->b_dead )
00124 {
00125
00126 ShowWindow( p_main_interface->hwndSlider, SW_HIDE);
00127 ShowWindow( p_main_interface->hwndLabel, SW_HIDE);
00128 ShowWindow( p_main_interface->hwndVol, SW_HIDE);
00129
00130 p_main_interface->TogglePlayButton( PAUSE_S );
00131 i_old_playing_status = PAUSE_S;
00132
00133 SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
00134 (WPARAM) 0, (LPARAM)(LPCTSTR) TEXT(""));
00135
00136 vlc_object_release( p_intf->p_sys->p_input );
00137 p_intf->p_sys->p_input = NULL;
00138 }
00139
00140 if( p_intf->p_sys->p_input )
00141 {
00142 input_thread_t *p_input = p_intf->p_sys->p_input;
00143
00144 if( !p_input->b_die )
00145 {
00146
00147 p_intf->p_sys->b_playing = 1;
00148
00149
00150 if( p_intf->p_sys->b_playing )
00151 {
00152
00153 if( p_intf->p_sys->b_slider_free )
00154 {
00155 vlc_value_t pos;
00156 char psz_time[ MSTRTIME_MAX_SIZE ];
00157 vlc_value_t time;
00158 mtime_t i_seconds;
00159
00160
00161 var_Get( p_input, "position", &pos );
00162 if( pos.f_float >= 0.0 )
00163 {
00164 p_intf->p_sys->i_slider_pos =
00165 (int)(SLIDER_MAX_POS * pos.f_float);
00166
00167 SendMessage( p_main_interface->hwndSlider, TBM_SETPOS,
00168 1, p_intf->p_sys->i_slider_pos );
00169
00170 var_Get( p_intf->p_sys->p_input, "time", &time );
00171 i_seconds = time.i_time / 1000000;
00172 secstotimestr ( psz_time, i_seconds );
00173
00174 SendMessage( p_main_interface->hwndLabel, WM_SETTEXT,
00175 (WPARAM)1, (LPARAM)_FROMMB(psz_time) );
00176 }
00177 }
00178 }
00179
00180
00181 p_main_interface->Update();
00182
00183
00184 var_Get( p_input, "state", &val );
00185 if( i_old_playing_status != val.i_int )
00186 {
00187 if( val.i_int == PAUSE_S )
00188 {
00189 p_main_interface->TogglePlayButton( PAUSE_S );
00190 }
00191 else
00192 {
00193 p_main_interface->TogglePlayButton( PLAYING_S );
00194 }
00195 i_old_playing_status = val.i_int;
00196 }
00197
00198
00199 var_Get( p_input, "rate", &val );
00200 if( i_old_rate != val.i_int )
00201 {
00202 TCHAR psz_text[15];
00203 _stprintf( psz_text + 2, _T("x%.2f"), 1000.0 / val.i_int );
00204 psz_text[0] = psz_text[1] = _T('\t');
00205
00206 SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
00207 (WPARAM) 1, (LPARAM)(LPCTSTR) psz_text );
00208
00209 i_old_rate = val.i_int;
00210 }
00211 }
00212 }
00213 else if( p_intf->p_sys->b_playing && !p_intf->b_die )
00214 {
00215 p_intf->p_sys->b_playing = 0;
00216 p_main_interface->TogglePlayButton( PAUSE_S );
00217 i_old_playing_status = PAUSE_S;
00218 }
00219
00220 if( p_intf->b_die )
00221 {
00222 vlc_mutex_unlock( &p_intf->change_lock );
00223
00224
00225
00226 return;
00227 }
00228
00229 vlc_mutex_unlock( &p_intf->change_lock );
00230 }
00231
00232
00233
00234
00235
00236
00237 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
00238 vlc_value_t old_val, vlc_value_t new_val, void *param )
00239 {
00240 intf_thread_t *p_intf = (intf_thread_t *)param;
00241
00242 if( p_intf->p_sys->pf_show_dialog )
00243 {
00244 p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,
00245 new_val.b_bool, 0 );
00246 }
00247
00248 return VLC_SUCCESS;
00249 }