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