Mercurial > mplayer.hg
annotate gui/mplayer/play.c @ 33477:49d9967970c0
Add option '-idle' to the GUI configuration file.
Also, add a check button for it to the preferences menu.
author | ib |
---|---|
date | Mon, 06 Jun 2011 14:08:18 +0000 |
parents | b8779b19730e |
children | 7e41f14e7778 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 | |
32881 | 22 #include "play.h" |
23 #include "gmplayer.h" | |
24 #include "gui/app.h" | |
25 #include "gui/interface.h" | |
26 #include "gui/skin/font.h" | |
27 #include "gui/skin/skin.h" | |
28 #include "gui/wm/wsxdnd.h" | |
29 #include "widgets.h" | |
23077 | 30 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
31 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
32 #include "help_mp.h" |
32881 | 33 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
34 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "libvo/video_out.h" |
32881 | 36 #include "mp_core.h" |
23077 | 37 #include "stream/stream.h" |
38 | |
39 int mplGotoTheNext = 1; | |
40 | |
32881 | 41 void mplFullScreen(void) |
23077 | 42 { |
32881 | 43 if (guiIntfStruct.NoWindow && guiIntfStruct.Playing) |
44 return; | |
45 | |
46 if (guiIntfStruct.Playing && appMPlayer.subWindow.isFullScreen) { | |
47 appMPlayer.subWindow.OldWidth = guiIntfStruct.MovieWidth; | |
48 appMPlayer.subWindow.OldHeight = guiIntfStruct.MovieHeight; | |
49 | |
50 switch (appMPlayer.sub.x) { | |
51 case -1: | |
52 appMPlayer.subWindow.OldX = wsMaxX / 2 - appMPlayer.subWindow.OldWidth / 2 + wsOrgX; | |
53 break; | |
54 | |
55 case -2: | |
56 appMPlayer.subWindow.OldX = wsMaxX - appMPlayer.subWindow.OldWidth + wsOrgX; | |
57 break; | |
58 | |
59 default: | |
60 appMPlayer.subWindow.OldX = appMPlayer.sub.x; | |
61 break; | |
62 } | |
23077 | 63 |
32881 | 64 switch (appMPlayer.sub.y) { |
65 case -1: | |
66 appMPlayer.subWindow.OldY = wsMaxY / 2 - appMPlayer.subWindow.OldHeight / 2 + wsOrgY; | |
67 break; | |
68 | |
69 case -2: | |
70 appMPlayer.subWindow.OldY = wsMaxY - appMPlayer.subWindow.OldHeight + wsOrgY; | |
71 break; | |
23077 | 72 |
32881 | 73 default: |
74 appMPlayer.subWindow.OldY = appMPlayer.sub.y; | |
75 break; | |
76 } | |
77 } | |
78 | |
79 if (guiIntfStruct.Playing || gtkShowVideoWindow) | |
80 wsFullScreen(&appMPlayer.subWindow); | |
81 | |
82 fullscreen = vo_fs = appMPlayer.subWindow.isFullScreen; | |
83 wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
84 | |
85 if (appMPlayer.menuIsPresent) | |
86 wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
87 | |
88 if (guiIntfStruct.Playing) | |
89 wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0); | |
90 else | |
91 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
23077 | 92 } |
93 | |
32881 | 94 void mplEnd(void) |
23077 | 95 { |
32881 | 96 plItem *next; |
23077 | 97 |
32881 | 98 if (!mplGotoTheNext && guiIntfStruct.Playing) { |
99 mplGotoTheNext = 1; | |
100 return; | |
101 } | |
23077 | 102 |
32881 | 103 if (guiIntfStruct.Playing && (next = gtkSet(gtkGetNextPlItem, 0, NULL)) && (plLastPlayed != next)) { |
104 plLastPlayed = next; | |
105 guiSetDF(guiIntfStruct.Filename, next->path, next->name); | |
106 guiIntfStruct.StreamType = STREAMTYPE_FILE; | |
107 guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1; | |
108 gfree((void **)&guiIntfStruct.AudioFile); | |
109 gfree((void **)&guiIntfStruct.Subtitlename); | |
110 } else { | |
111 if (guiIntfStruct.FilenameChanged || guiIntfStruct.NewPlay) | |
112 return; | |
23077 | 113 |
32881 | 114 guiIntfStruct.TimeSec = 0; |
115 guiIntfStruct.Position = 0; | |
116 guiIntfStruct.AudioType = 0; | |
117 guiIntfStruct.NoWindow = False; | |
23077 | 118 |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
119 #ifdef CONFIG_DVDREAD |
32881 | 120 guiIntfStruct.DVD.current_title = 1; |
121 guiIntfStruct.DVD.current_chapter = 1; | |
122 guiIntfStruct.DVD.current_angle = 1; | |
23077 | 123 #endif |
124 | |
32881 | 125 if (!appMPlayer.subWindow.isFullScreen && gtkShowVideoWindow) { |
126 wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height); | |
127 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
128 } else | |
129 wsVisibleWindow(&appMPlayer.subWindow, wsHideWindow); | |
130 | |
131 guiGetEvent(guiCEvent, guiSetStop); | |
132 mplSubRender = 1; | |
133 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
134 wsClearWindow(appMPlayer.subWindow); | |
135 wsPostRedisplay(&appMPlayer.subWindow); | |
23077 | 136 } |
137 } | |
138 | |
32881 | 139 void mplPlay(void) |
23077 | 140 { |
32881 | 141 if (!guiIntfStruct.Filename || |
142 (guiIntfStruct.Filename[0] == 0) || | |
143 (guiIntfStruct.Playing == 1)) | |
144 return; | |
23077 | 145 |
32881 | 146 if (guiIntfStruct.Playing == 2) { |
147 mplPause(); | |
148 return; | |
149 } | |
150 | |
151 guiGetEvent(guiCEvent, (void *)guiSetPlay); | |
152 mplSubRender = 0; | |
153 wsSetBackgroundRGB(&appMPlayer.subWindow, 0, 0, 0); | |
154 wsClearWindow(appMPlayer.subWindow); | |
23077 | 155 } |
156 | |
32881 | 157 void mplPause(void) |
23077 | 158 { |
32881 | 159 if (!guiIntfStruct.Playing) |
160 return; | |
161 | |
162 if (guiIntfStruct.Playing == 1) { | |
163 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); | |
164 cmd->id = MP_CMD_PAUSE; | |
165 cmd->name = strdup("pause"); | |
166 mp_input_queue_cmd(cmd); | |
167 } else | |
168 guiIntfStruct.Playing = 1; | |
23077 | 169 } |
170 | |
32881 | 171 void mplState(void) |
172 { | |
173 if (guiIntfStruct.Playing == 0 || guiIntfStruct.Playing == 2) { | |
174 btnModify(evPlaySwitchToPause, btnReleased); | |
175 btnModify(evPauseSwitchToPlay, btnDisabled); | |
176 } else { | |
177 btnModify(evPlaySwitchToPause, btnDisabled); | |
178 btnModify(evPauseSwitchToPlay, btnReleased); | |
179 } | |
23077 | 180 } |
181 | |
32971 | 182 void mplRelSeek(float sec) |
32881 | 183 { |
32971 | 184 rel_seek_secs = sec; |
32881 | 185 abs_seek_pos = 0; |
186 } | |
187 | |
32971 | 188 void mplAbsSeek(float percent) |
32881 | 189 { |
190 if (guiIntfStruct.StreamType == STREAMTYPE_STREAM) | |
191 return; | |
192 | |
32971 | 193 rel_seek_secs = percent / 100.0; |
32881 | 194 abs_seek_pos = 3; |
23077 | 195 } |
196 | |
32881 | 197 void ChangeSkin(char *name) |
23077 | 198 { |
32893 | 199 int prev, bprev; |
32881 | 200 |
201 prev = appMPlayer.menuIsPresent; | |
202 bprev = appMPlayer.barIsPresent; | |
203 | |
204 mainVisible = 0; | |
205 | |
32893 | 206 if (skinRead(name) != 0) { |
207 if (skinRead(skinName) != 0) { | |
32894 | 208 mainVisible = 1; |
209 return; | |
32893 | 210 } |
32881 | 211 } |
212 | |
213 // reload menu window | |
23077 | 214 |
32881 | 215 if (prev && appMPlayer.menuIsPresent) { |
216 free(mplMenuDrawBuffer); | |
33084 | 217 mplMenuDrawBuffer = calloc(1, appMPlayer.menu.Bitmap.ImageSize); |
32881 | 218 |
219 if (!mplMenuDrawBuffer) { | |
220 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB); | |
221 return; | |
222 } | |
23077 | 223 |
33084 | 224 wsResizeWindow(&appMPlayer.menuWindow, appMPlayer.menu.width, appMPlayer.menu.height); |
225 wsResizeImage(&appMPlayer.menuWindow, appMPlayer.menu.width, appMPlayer.menu.height); | |
226 wsSetShape(&appMPlayer.menuWindow, appMPlayer.menu.Mask.Image); | |
32881 | 227 wsVisibleWindow(&appMPlayer.menuWindow, wsHideWindow); |
228 } else | |
229 mplMenuInit(); | |
230 | |
231 // reload sub window | |
23077 | 232 |
32881 | 233 if (appMPlayer.sub.Bitmap.Image) |
234 wsResizeImage(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Width, appMPlayer.sub.Bitmap.Height); | |
235 | |
236 if (!appMPlayer.subWindow.isFullScreen && !guiIntfStruct.Playing) { | |
237 wsResizeWindow(&appMPlayer.subWindow, appMPlayer.sub.width, appMPlayer.sub.height); | |
238 wsMoveWindow(&appMPlayer.subWindow, True, appMPlayer.sub.x, appMPlayer.sub.y); | |
239 } | |
240 | |
241 if (appMPlayer.sub.Bitmap.Image) | |
242 wsConvert(&appMPlayer.subWindow, appMPlayer.sub.Bitmap.Image, appMPlayer.sub.Bitmap.ImageSize); | |
23077 | 243 |
32881 | 244 if (!guiIntfStruct.Playing) { |
245 mplSubRender = 1; | |
246 wsSetBackgroundRGB(&appMPlayer.subWindow, appMPlayer.sub.R, appMPlayer.sub.G, appMPlayer.sub.B); | |
247 wsClearWindow(appMPlayer.subWindow); | |
248 wsPostRedisplay(&appMPlayer.subWindow); | |
249 } | |
250 | |
251 // reload play bar | |
252 | |
253 if (bprev) | |
254 wsDestroyWindow(&appMPlayer.barWindow); | |
255 | |
256 mplPBInit(); | |
23077 | 257 |
32881 | 258 // reload main window |
259 | |
260 free(mplDrawBuffer); | |
261 mplDrawBuffer = calloc(1, appMPlayer.main.Bitmap.ImageSize); | |
23077 | 262 |
32881 | 263 if (!mplDrawBuffer) { |
264 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_NEMDB); | |
265 return; | |
266 } | |
23077 | 267 |
32881 | 268 wsDestroyWindow(&appMPlayer.mainWindow); |
269 | |
270 wsCreateWindow(&appMPlayer.mainWindow, appMPlayer.main.x, appMPlayer.main.y, appMPlayer.main.width, appMPlayer.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); | |
271 wsCreateImage(&appMPlayer.mainWindow, appMPlayer.main.Bitmap.Width, appMPlayer.main.Bitmap.Height); | |
272 wsSetShape(&appMPlayer.mainWindow, appMPlayer.main.Mask.Image); | |
273 wsSetIcon(wsDisplay, appMPlayer.mainWindow.WindowID, guiIcon, guiIconMask); | |
23077 | 274 |
32881 | 275 appMPlayer.mainWindow.ReDraw = (void *)mplMainDraw; |
276 appMPlayer.mainWindow.MouseHandler = mplMainMouseHandle; | |
277 appMPlayer.mainWindow.KeyHandler = mplMainKeyHandle; | |
278 appMPlayer.mainWindow.DandDHandler = mplDandDHandler; | |
279 | |
280 wsXDNDMakeAwareness(&appMPlayer.mainWindow); | |
23077 | 281 |
32881 | 282 if (!appMPlayer.mainDecoration) |
283 wsWindowDecoration(&appMPlayer.mainWindow, 0); | |
284 | |
285 wsVisibleWindow(&appMPlayer.mainWindow, wsShowWindow); | |
286 mainVisible = 1; | |
287 | |
288 btnModify(evSetVolume, guiIntfStruct.Volume); | |
289 btnModify(evSetBalance, guiIntfStruct.Balance); | |
290 btnModify(evSetMoviePosition, guiIntfStruct.Position); | |
291 btnModify(evFullScreen, !appMPlayer.subWindow.isFullScreen); | |
23077 | 292 |
32881 | 293 wsSetLayer(wsDisplay, appMPlayer.mainWindow.WindowID, appMPlayer.subWindow.isFullScreen); |
294 wsSetLayer(wsDisplay, appMPlayer.menuWindow.WindowID, appMPlayer.subWindow.isFullScreen); | |
295 } | |
296 | |
297 void mplSetFileName(char *dir, char *name, int type) | |
298 { | |
299 if (!name) | |
300 return; | |
23077 | 301 |
32881 | 302 if (!dir) |
303 guiSetFilename(guiIntfStruct.Filename, name) | |
304 else | |
305 guiSetDF(guiIntfStruct.Filename, dir, name) | |
23077 | 306 |
32881 | 307 guiIntfStruct.StreamType = type; |
308 gfree((void **)&guiIntfStruct.AudioFile); | |
309 gfree((void **)&guiIntfStruct.Subtitlename); | |
23077 | 310 } |
311 | |
32881 | 312 void mplCurr(void) |
23077 | 313 { |
32881 | 314 plItem *curr; |
315 int stop = 0; | |
23077 | 316 |
32881 | 317 if (guiIntfStruct.Playing == 2) |
318 return; | |
23077 | 319 |
32881 | 320 switch (guiIntfStruct.StreamType) { |
321 #ifdef CONFIG_DVDREAD | |
322 case STREAMTYPE_DVD: | |
323 break; | |
32953 | 324 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
325 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
326 #ifdef CONFIG_VCD |
32881 | 327 case STREAMTYPE_VCD: |
328 break; | |
32953 | 329 #endif |
32881 | 330 |
331 default: | |
332 | |
333 curr = gtkSet(gtkGetCurrPlItem, 0, NULL); | |
334 | |
335 if (curr) { | |
336 mplSetFileName(curr->path, curr->name, STREAMTYPE_FILE); | |
337 mplGotoTheNext = 0; | |
338 break; | |
339 } | |
340 | |
341 return; | |
342 } | |
343 | |
344 if (stop) | |
345 mplEventHandling(evStop, 0); | |
346 | |
347 if (guiIntfStruct.Playing == 1) | |
348 mplEventHandling(evPlay, 0); | |
23077 | 349 } |
350 | |
32881 | 351 void mplPrev(void) |
23077 | 352 { |
32881 | 353 plItem *prev; |
354 int stop = 0; | |
355 | |
356 if (guiIntfStruct.Playing == 2) | |
357 return; | |
358 | |
359 switch (guiIntfStruct.StreamType) { | |
360 #ifdef CONFIG_DVDREAD | |
361 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
362 |
32881 | 363 if (--guiIntfStruct.DVD.current_chapter == 0) { |
364 guiIntfStruct.DVD.current_chapter = 1; | |
365 | |
366 if (--guiIntfStruct.DVD.current_title <= 0) { | |
367 guiIntfStruct.DVD.current_title = 1; | |
368 stop = 1; | |
369 } | |
370 } | |
371 | |
372 guiIntfStruct.Track = guiIntfStruct.DVD.current_title; | |
373 break; | |
32953 | 374 #endif |
32881 | 375 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
376 #ifdef CONFIG_VCD |
32881 | 377 case STREAMTYPE_VCD: |
378 if (--guiIntfStruct.Track == 0) { | |
379 guiIntfStruct.Track = 1; | |
380 stop = 1; | |
381 } | |
382 break; | |
32953 | 383 #endif |
32881 | 384 |
385 default: | |
386 | |
387 prev = gtkSet(gtkGetPrevPlItem, 0, NULL); | |
388 | |
389 if (prev) { | |
390 mplSetFileName(prev->path, prev->name, STREAMTYPE_FILE); | |
391 mplGotoTheNext = 0; | |
392 break; | |
393 } | |
394 | |
395 return; | |
396 } | |
397 | |
398 if (stop) | |
399 mplEventHandling(evStop, 0); | |
400 | |
401 if (guiIntfStruct.Playing == 1) | |
402 mplEventHandling(evPlay, 0); | |
23077 | 403 } |
404 | |
32881 | 405 void mplNext(void) |
23077 | 406 { |
32881 | 407 int stop = 0; |
408 plItem *next; | |
23077 | 409 |
32881 | 410 if (guiIntfStruct.Playing == 2) |
411 return; | |
412 | |
413 switch (guiIntfStruct.StreamType) { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
414 #ifdef CONFIG_DVDREAD |
32881 | 415 case STREAMTYPE_DVD: |
416 | |
417 if (guiIntfStruct.DVD.current_chapter++ == guiIntfStruct.DVD.chapters) { | |
418 guiIntfStruct.DVD.current_chapter = 1; | |
419 | |
420 if (++guiIntfStruct.DVD.current_title > guiIntfStruct.DVD.titles) { | |
421 guiIntfStruct.DVD.current_title = guiIntfStruct.DVD.titles; | |
422 stop = 1; | |
423 } | |
424 } | |
425 | |
426 guiIntfStruct.Track = guiIntfStruct.DVD.current_title; | |
427 break; | |
32953 | 428 #endif |
32881 | 429 |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
430 #ifdef CONFIG_VCD |
32881 | 431 case STREAMTYPE_VCD: |
33003 | 432 |
433 if (++guiIntfStruct.Track >= guiIntfStruct.VCDTracks) { | |
32881 | 434 guiIntfStruct.Track = guiIntfStruct.VCDTracks; |
33003 | 435 |
436 if (guiIntfStruct.VCDTracks > 1) | |
437 guiIntfStruct.Track--; | |
438 | |
32881 | 439 stop = 1; |
440 } | |
33003 | 441 |
32881 | 442 break; |
32953 | 443 #endif |
32881 | 444 |
445 default: | |
446 | |
447 next = gtkSet(gtkGetNextPlItem, 0, NULL); | |
448 | |
449 if (next) { | |
450 mplSetFileName(next->path, next->name, STREAMTYPE_FILE); | |
451 mplGotoTheNext = 0; | |
452 break; | |
453 } | |
454 | |
455 return; | |
456 } | |
457 | |
458 if (stop) | |
459 mplEventHandling(evStop, 0); | |
460 | |
461 if (guiIntfStruct.Playing == 1) | |
462 mplEventHandling(evPlay, 0); | |
23077 | 463 } |