23077
|
1
|
|
2 #include <inttypes.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <stdio.h>
|
|
5 #include <string.h>
|
|
6
|
|
7 #include <unistd.h>
|
|
8 #include <signal.h>
|
|
9
|
|
10 #include "wm/ws.h"
|
|
11 #include "wm/wsxdnd.h"
|
|
12 #include "../config.h"
|
|
13 #include "../help_mp.h"
|
|
14 #include "../libvo/x11_common.h"
|
|
15 #include "../libvo/video_out.h"
|
|
16 #include "../input/input.h"
|
|
17
|
|
18 #include "app.h"
|
|
19
|
|
20 #include "wm/wskeys.h"
|
|
21 #include "interface.h"
|
|
22
|
|
23 #include "widgets.h"
|
|
24 #include "gmplayer.h"
|
|
25 #include "play.h"
|
|
26
|
|
27 #include "skin/skin.h"
|
|
28 #include "skin/font.h"
|
|
29
|
|
30 #include "stream/stream.h"
|
|
31
|
|
32 extern float rel_seek_secs;
|
|
33 extern int abs_seek_pos;
|
|
34
|
|
35 int mplGotoTheNext = 1;
|
|
36
|
|
37 void mplFullScreen( void )
|
|
38 {
|
|
39 if ( guiIntfStruct.NoWindow && guiIntfStruct.Playing ) return;
|
|
40
|
|
41 if ( ( guiIntfStruct.Playing )&&( appMPlayer.subWindow.isFullScreen ) )
|
|
42 {
|
|
43 appMPlayer.subWindow.OldWidth=guiIntfStruct.MovieWidth; appMPlayer.subWindow.OldHeight=guiIntfStruct.MovieHeight;
|
|
44 switch ( appMPlayer.sub.x )
|
|
45 {
|
|
46 case -1: appMPlayer.subWindow.OldX=( wsMaxX / 2 ) - ( appMPlayer.subWindow.OldWidth / 2 ) + wsOrgX; break;
|
|
47 case -2: appMPlayer.subWindow.OldX=wsMaxX - appMPlayer.subWindow.OldWidth + wsOrgX; break;
|
|
48 default: appMPlayer.subWindow.OldX=appMPlayer.sub.x; break;
|
|
49 }
|
|
50 switch ( appMPlayer.sub.y )
|
|
51 {
|
|
52 case -1: appMPlayer.subWindow.OldY=( wsMaxY / 2 ) - ( appMPlayer.subWindow.OldHeight / 2 ) + wsOrgY; break;
|
|
53 case -2: appMPlayer.subWindow.OldY=wsMaxY - appMPlayer.subWindow.OldHeight + wsOrgY; break;
|
|
54 default: appMPlayer.subWindow.OldY=appMPlayer.sub.y; break;
|
|
55 }
|
|
56 }
|
|
57 if ( guiIntfStruct.Playing || gtkShowVideoWindow ) wsFullScreen( &appMPlayer.subWindow );
|
|
58 fullscreen=vo_fs=appMPlayer.subWindow.isFullScreen;
|
|
59 wsSetLayer( wsDisplay,appMPlayer.mainWindow.WindowID,appMPlayer.subWindow.isFullScreen );
|
|
60 if ( appMPlayer.menuIsPresent ) wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,appMPlayer.subWindow.isFullScreen );
|
|
61
|
|
62 if ( guiIntfStruct.Playing ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
|
|
63 else wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
|
|
64 }
|
|
65
|
|
66 void mplEnd( void )
|
|
67 {
|
|
68 plItem * next;
|
|
69
|
|
70 if ( !mplGotoTheNext && guiIntfStruct.Playing) { mplGotoTheNext=1; return; }
|
|
71
|
|
72 if ( guiIntfStruct.Playing && (next=gtkSet( gtkGetNextPlItem,0,NULL )) && plLastPlayed != next )
|
|
73 {
|
|
74 plLastPlayed=next;
|
|
75 guiSetDF( guiIntfStruct.Filename,next->path,next->name );
|
|
76 guiIntfStruct.StreamType=STREAMTYPE_FILE;
|
|
77 guiIntfStruct.FilenameChanged=guiIntfStruct.NewPlay=1;
|
|
78 gfree( (void **)&guiIntfStruct.AudioFile );
|
|
79 gfree( (void **)&guiIntfStruct.Subtitlename );
|
|
80 }
|
|
81 else
|
|
82 {
|
|
83 if ( guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay ) return;
|
|
84
|
|
85 guiIntfStruct.TimeSec=0;
|
|
86 guiIntfStruct.Position=0;
|
|
87 guiIntfStruct.AudioType=0;
|
|
88 guiIntfStruct.NoWindow=False;
|
|
89
|
|
90 #ifdef USE_DVDREAD
|
|
91 guiIntfStruct.DVD.current_title=1;
|
|
92 guiIntfStruct.DVD.current_chapter=1;
|
|
93 guiIntfStruct.DVD.current_angle=1;
|
|
94 #endif
|
|
95
|
|
96 if ( !appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow)
|
|
97 {
|
|
98 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
|
99 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
|
100 }
|
|
101 else wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow );
|
|
102 guiGetEvent( guiCEvent,guiSetStop );
|
|
103 mplSubRender=1;
|
|
104 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
|
|
105 wsClearWindow( appMPlayer.subWindow );
|
|
106 wsPostRedisplay( &appMPlayer.subWindow );
|
|
107 }
|
|
108 }
|
|
109
|
|
110 void mplPlay( void )
|
|
111 {
|
|
112 if ( ( !guiIntfStruct.Filename )||
|
|
113 ( guiIntfStruct.Filename[0] == 0 )||
|
|
114 ( guiIntfStruct.Playing == 1 ) ) return;
|
|
115 if ( guiIntfStruct.Playing == 2 ) { mplPause(); return; }
|
|
116 guiGetEvent( guiCEvent,(void *)guiSetPlay );
|
|
117 mplSubRender=0;
|
|
118 wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 );
|
|
119 wsClearWindow( appMPlayer.subWindow );
|
|
120 }
|
|
121
|
|
122 void mplPause( void )
|
|
123 {
|
|
124 if ( !guiIntfStruct.Playing ) return;
|
|
125 if ( guiIntfStruct.Playing == 1 )
|
|
126 {
|
|
127 mp_cmd_t * cmd = calloc( 1,sizeof( *cmd ) );
|
|
128 cmd->id=MP_CMD_PAUSE;
|
|
129 cmd->name=strdup("pause");
|
|
130 mp_input_queue_cmd(cmd);
|
|
131 } else guiIntfStruct.Playing=1;
|
|
132 }
|
|
133
|
|
134 void mplState( void )
|
|
135 {
|
|
136 if ( ( guiIntfStruct.Playing == 0 )||( guiIntfStruct.Playing == 2 ) )
|
|
137 {
|
|
138 btnModify( evPlaySwitchToPause,btnReleased );
|
|
139 btnModify( evPauseSwitchToPlay,btnDisabled );
|
|
140 }
|
|
141 else
|
|
142 {
|
|
143 btnModify( evPlaySwitchToPause,btnDisabled );
|
|
144 btnModify( evPauseSwitchToPlay,btnReleased );
|
|
145 }
|
|
146 }
|
|
147
|
|
148 float mplGetPosition( void )
|
|
149 { // return 0.0 ... 100.0
|
|
150 return guiIntfStruct.Position;
|
|
151 }
|
|
152
|
|
153 void mplRelSeek( float s )
|
|
154 { // -+s
|
|
155 rel_seek_secs=s; abs_seek_pos=0;
|
|
156 }
|
|
157
|
|
158 void mplAbsSeek( float s )
|
|
159 { // 0.0 ... 100.0
|
|
160 if ( guiIntfStruct.StreamType == STREAMTYPE_STREAM ) return;
|
|
161 rel_seek_secs=0.01*s; abs_seek_pos=3;
|
|
162 }
|
|
163
|
|
164 listItems tmpList;
|
|
165
|
|
166 void ChangeSkin( char * name )
|
|
167 {
|
|
168 int ret;
|
|
169 int prev = appMPlayer.menuIsPresent;
|
|
170 int bprev = appMPlayer.barIsPresent;
|
|
171
|
|
172 mainVisible=0;
|
|
173
|
|
174 appInitStruct( &tmpList );
|
|
175 skinAppMPlayer=&tmpList;
|
|
176 fntFreeFont();
|
|
177 ret=skinRead( name );
|
|
178
|
|
179 appInitStruct( &tmpList );
|
|
180 skinAppMPlayer=&appMPlayer;
|
|
181 appInitStruct( &appMPlayer );
|
|
182 if ( ret ) name=skinName;
|
|
183 if ( skinRead( name ) )
|
|
184 {
|
|
185 mainVisible=1;
|
|
186 return;
|
|
187 }
|
|
188
|
|
189 // --- reload menu window
|
|
190
|
|
191 if ( prev && appMPlayer.menuIsPresent )
|
|
192 {
|
|
193 if ( mplMenuDrawBuffer ) free( mplMenuDrawBuffer );
|
|
194 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
195 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; }
|
|
196 wsResizeWindow( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
|
197 wsResizeImage( &appMPlayer.menuWindow,appMPlayer.menuBase.width,appMPlayer.menuBase.height );
|
|
198 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image );
|
|
199 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );
|
|
200 } else { mplMenuInit(); }
|
|
201
|
|
202 // --- reload sub window
|
|
203 if ( appMPlayer.sub.Bitmap.Image ) wsResizeImage( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Width,appMPlayer.sub.Bitmap.Height );
|
|
204 if ( ( !appMPlayer.subWindow.isFullScreen )&&( !guiIntfStruct.Playing ) )
|
|
205 {
|
|
206 wsResizeWindow( &appMPlayer.subWindow,appMPlayer.sub.width,appMPlayer.sub.height );
|
|
207 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y );
|
|
208 }
|
|
209 if ( appMPlayer.sub.Bitmap.Image ) wsConvert( &appMPlayer.subWindow,appMPlayer.sub.Bitmap.Image,appMPlayer.sub.Bitmap.ImageSize );
|
|
210 if ( !guiIntfStruct.Playing )
|
|
211 {
|
|
212 mplSubRender=1;
|
|
213 wsSetBackgroundRGB( &appMPlayer.subWindow,appMPlayer.sub.R,appMPlayer.sub.G,appMPlayer.sub.B );
|
|
214 wsClearWindow( appMPlayer.subWindow );
|
|
215 wsPostRedisplay( &appMPlayer.subWindow );
|
|
216 }
|
|
217
|
|
218 // --- reload play bar
|
|
219 if ( bprev ) wsDestroyWindow( &appMPlayer.barWindow );
|
|
220 mplPBInit();
|
|
221
|
|
222 // --- reload main window
|
|
223 if ( mplDrawBuffer ) free( mplDrawBuffer );
|
|
224 if ( ( mplDrawBuffer = calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
|
|
225 { mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_NEMDB ); return; }
|
|
226
|
|
227 wsDestroyWindow( &appMPlayer.mainWindow );
|
|
228
|
|
229 wsCreateWindow( &appMPlayer.mainWindow,
|
|
230 appMPlayer.main.x,appMPlayer.main.y,appMPlayer.main.width,appMPlayer.main.height,
|
|
231 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsShowFrame|wsMaxSize|wsHideWindow,"MPlayer" );
|
|
232 wsCreateImage( &appMPlayer.mainWindow,appMPlayer.main.Bitmap.Width,appMPlayer.main.Bitmap.Height );
|
|
233 wsSetShape( &appMPlayer.mainWindow,appMPlayer.main.Mask.Image );
|
|
234 wsSetIcon( wsDisplay,appMPlayer.mainWindow.WindowID,guiIcon,guiIconMask );
|
|
235
|
|
236 appMPlayer.mainWindow.ReDraw=(void *)mplMainDraw;
|
|
237 appMPlayer.mainWindow.MouseHandler=mplMainMouseHandle;
|
|
238 appMPlayer.mainWindow.KeyHandler=mplMainKeyHandle;
|
|
239 appMPlayer.mainWindow.DandDHandler=mplDandDHandler;
|
|
240
|
|
241 wsXDNDMakeAwareness( &appMPlayer.mainWindow );
|
|
242 if ( !appMPlayer.mainDecoration ) wsWindowDecoration( &appMPlayer.mainWindow,0 );
|
|
243 wsVisibleWindow( &appMPlayer.mainWindow,wsShowWindow );
|
|
244 mainVisible=1;
|
|
245 // ---
|
|
246
|
|
247 btnModify( evSetVolume,guiIntfStruct.Volume );
|
|
248 btnModify( evSetBalance,guiIntfStruct.Balance );
|
|
249 btnModify( evSetMoviePosition,guiIntfStruct.Position );
|
|
250 btnModify( evFullScreen,!appMPlayer.subWindow.isFullScreen );
|
|
251
|
|
252 wsSetLayer( wsDisplay,appMPlayer.mainWindow.WindowID,appMPlayer.subWindow.isFullScreen );
|
|
253 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,appMPlayer.subWindow.isFullScreen );
|
|
254
|
|
255 }
|
|
256
|
|
257 void mplSetFileName( char * dir,char * name,int type )
|
|
258 {
|
|
259 if ( !name ) return;
|
|
260
|
|
261 if ( !dir ) guiSetFilename( guiIntfStruct.Filename,name )
|
|
262 else guiSetDF( guiIntfStruct.Filename,dir,name );
|
|
263
|
|
264 // filename=guiIntfStruct.Filename;
|
|
265 guiIntfStruct.StreamType=type;
|
|
266 gfree( (void **)&guiIntfStruct.AudioFile );
|
|
267 gfree( (void **)&guiIntfStruct.Subtitlename );
|
|
268 }
|
|
269
|
|
270 void mplCurr( void )
|
|
271 {
|
|
272 plItem * curr;
|
|
273 int stop = 0;
|
|
274
|
|
275 if ( guiIntfStruct.Playing == 2 ) return;
|
|
276 switch ( guiIntfStruct.StreamType )
|
|
277 {
|
|
278 #ifdef USE_DVDREAD
|
|
279 case STREAMTYPE_DVD:
|
|
280 break;
|
|
281 #endif
|
|
282 #ifdef HAVE_VCD
|
|
283 case STREAMTYPE_VCD:
|
|
284 break;
|
|
285 #endif
|
|
286 default:
|
|
287 if ( (curr=gtkSet( gtkGetCurrPlItem,0,NULL)) )
|
|
288 {
|
|
289 mplSetFileName( curr->path,curr->name,STREAMTYPE_FILE );
|
|
290 mplGotoTheNext=0;
|
|
291 break;
|
|
292 }
|
|
293 return;
|
|
294 }
|
|
295 if ( stop ) mplEventHandling( evStop,0 );
|
|
296 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
|
|
297 }
|
|
298
|
|
299
|
|
300 void mplPrev( void )
|
|
301 {
|
|
302 plItem * prev;
|
|
303 int stop = 0;
|
|
304
|
|
305 if ( guiIntfStruct.Playing == 2 ) return;
|
|
306 switch ( guiIntfStruct.StreamType )
|
|
307 {
|
|
308 #ifdef USE_DVDREAD
|
|
309 case STREAMTYPE_DVD:
|
|
310 if ( --guiIntfStruct.DVD.current_chapter == 0 )
|
|
311 {
|
|
312 guiIntfStruct.DVD.current_chapter=1;
|
|
313 if ( --guiIntfStruct.DVD.current_title <= 0 ) { guiIntfStruct.DVD.current_title=1; stop=1; }
|
|
314 }
|
|
315 guiIntfStruct.Track=guiIntfStruct.DVD.current_title;
|
|
316 break;
|
|
317 #endif
|
|
318 #ifdef HAVE_VCD
|
|
319 case STREAMTYPE_VCD:
|
|
320 if ( --guiIntfStruct.Track == 0 ) { guiIntfStruct.Track=1; stop=1; }
|
|
321 break;
|
|
322 #endif
|
|
323 default:
|
|
324 if ( (prev=gtkSet( gtkGetPrevPlItem,0,NULL)) )
|
|
325 {
|
|
326 mplSetFileName( prev->path,prev->name,STREAMTYPE_FILE );
|
|
327 mplGotoTheNext=0;
|
|
328 break;
|
|
329 }
|
|
330 return;
|
|
331 }
|
|
332 if ( stop ) mplEventHandling( evStop,0 );
|
|
333 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
|
|
334 }
|
|
335
|
|
336 void mplNext( void )
|
|
337 {
|
|
338 int stop = 0;
|
|
339 plItem * next;
|
|
340
|
|
341 if ( guiIntfStruct.Playing == 2 ) return;
|
|
342 switch ( guiIntfStruct.StreamType )
|
|
343 {
|
|
344 #ifdef USE_DVDREAD
|
|
345 case STREAMTYPE_DVD:
|
|
346 if ( guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters )
|
|
347 {
|
|
348 guiIntfStruct.DVD.current_chapter=1;
|
|
349 if ( ++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles ) { guiIntfStruct.DVD.current_title=guiIntfStruct.DVD.titles; stop=1; }
|
|
350 }
|
|
351 guiIntfStruct.Track=guiIntfStruct.DVD.current_title;
|
|
352 break;
|
|
353 #endif
|
|
354 #ifdef HAVE_VCD
|
|
355 case STREAMTYPE_VCD:
|
|
356 if ( ++guiIntfStruct.Track > guiIntfStruct.VCDTracks ) { guiIntfStruct.Track=guiIntfStruct.VCDTracks; stop=1; }
|
|
357 break;
|
|
358 #endif
|
|
359 default:
|
|
360 if ( (next=gtkSet( gtkGetNextPlItem,0,NULL)) )
|
|
361 {
|
|
362 mplSetFileName( next->path,next->name,STREAMTYPE_FILE );
|
|
363 mplGotoTheNext=0;
|
|
364 break;
|
|
365 }
|
|
366 return;
|
|
367 }
|
|
368 if ( stop ) mplEventHandling( evStop,0 );
|
|
369 if ( guiIntfStruct.Playing == 1 ) mplEventHandling( evPlay,0 );
|
|
370 }
|