Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 36262:703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
The change of the ratio won't restart the movie any longer now.
Based on a patch by Stephen Sheldon, sfsheldo gmail com.
author | ib |
---|---|
date | Sat, 13 Jul 2013 19:45:12 +0000 |
parents | c667e34fb941 |
children | bf9a9e07377a |
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 |
35437 | 19 /** |
20 * @file | |
21 * @brief User interface actions | |
22 */ | |
23 | |
23077 | 24 #include <stdlib.h> |
25 #include <string.h> | |
26 | |
33556 | 27 #include "actions.h" |
35528 | 28 #include "ui.h" |
36032 | 29 #include "gui/interface.h" |
35525 | 30 #include "gui/app/app.h" |
35771 | 31 #include "gui/app/cfg.h" |
35525 | 32 #include "gui/app/gui.h" |
35771 | 33 #include "gui/dialog/dialog.h" |
32881 | 34 #include "gui/skin/skin.h" |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
35 #include "gui/util/list.h" |
33739 | 36 #include "gui/util/mem.h" |
33737 | 37 #include "gui/util/string.h" |
35435 | 38 #include "gui/wm/ws.h" |
32881 | 39 #include "gui/wm/wsxdnd.h" |
23077 | 40 |
35771 | 41 #include "access_mpcontext.h" |
42 #include "config.h" | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
43 #include "help_mp.h" |
36032 | 44 #include "m_property.h" |
45 #include "mixer.h" | |
46 #include "mp_core.h" | |
47 #include "mp_msg.h" | |
48 #include "mpcommon.h" | |
49 #include "mplayer.h" | |
32881 | 50 #include "input/input.h" |
35431 | 51 #include "libmpdemux/demuxer.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
52 #include "libvo/video_out.h" |
35771 | 53 #include "libvo/wskeys.h" |
54 #include "libvo/x11_common.h" | |
55 #include "osdep/timer.h" | |
56 #include "stream/stream.h" | |
57 #include "sub/sub.h" | |
58 | |
35776 | 59 #define GUI_REDRAW_WAIT 375 // in milliseconds |
35771 | 60 |
35777 | 61 int uiLoadPlay; |
62 | |
35775 | 63 static unsigned int last_redraw_time; |
35771 | 64 |
35776 | 65 /** |
66 * @brief Clear information not used for this @a type of stream. | |
67 * | |
68 * @param type stream type | |
69 */ | |
35771 | 70 static void MediumPrepare(int type) |
71 { | |
72 switch (type) { | |
73 case STREAMTYPE_DVD: | |
74 listMgr(PLAYLIST_DELETE, 0); | |
75 break; | |
76 | |
77 case STREAMTYPE_CDDA: | |
78 case STREAMTYPE_VCD: | |
79 listMgr(PLAYLIST_DELETE, 0); | |
80 case STREAMTYPE_FILE: | |
81 case STREAMTYPE_STREAM: | |
82 case STREAMTYPE_PLAYLIST: | |
83 guiInfo.AudioStreams = 0; | |
84 guiInfo.Subtitles = 0; | |
85 guiInfo.Chapters = 0; | |
86 guiInfo.Angles = 0; | |
87 break; | |
88 } | |
89 } | |
90 | |
35773 | 91 void uiEvent(int ev, float param) |
35771 | 92 { |
93 int iparam = (int)param, osd; | |
94 mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
95 float aspect; |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
96 char cmd[32]; |
35771 | 97 |
35773 | 98 switch (ev) { |
35771 | 99 /* user events */ |
100 case evExit: | |
101 mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0); | |
102 break; | |
103 | |
104 case evLoadURL: | |
105 gtkShow(evLoadURL, NULL); | |
106 break; | |
107 | |
108 case ivSetAudio: | |
109 | |
110 if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam) | |
111 break; | |
112 | |
113 mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
114 break; | |
115 | |
116 case ivSetVideo: | |
117 | |
118 if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam) | |
119 break; | |
120 | |
121 mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
122 break; | |
123 | |
124 case ivSetSubtitle: | |
125 mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
126 break; | |
127 | |
128 #ifdef CONFIG_CDDA | |
129 case ivSetCDTrack: | |
130 guiInfo.Track = iparam; | |
131 | |
132 case evPlayCD: | |
133 guiInfo.StreamType = STREAMTYPE_CDDA; | |
134 goto play; | |
135 | |
136 #endif | |
137 #ifdef CONFIG_VCD | |
138 case ivSetVCDTrack: | |
139 guiInfo.Track = iparam; | |
140 | |
141 case evPlayVCD: | |
142 guiInfo.StreamType = STREAMTYPE_VCD; | |
143 goto play; | |
144 | |
145 #endif | |
146 #ifdef CONFIG_DVDREAD | |
147 case ivSetDVDSubtitle: | |
148 dvdsub_id = iparam; | |
35773 | 149 uiEvent(ivPlayDVD, 0); |
35771 | 150 break; |
151 | |
152 case ivSetDVDAudio: | |
153 audio_id = iparam; | |
35773 | 154 uiEvent(ivPlayDVD, 0); |
35771 | 155 break; |
156 | |
157 case ivSetDVDChapter: | |
158 guiInfo.Chapter = iparam; | |
35773 | 159 uiEvent(ivPlayDVD, 0); |
35771 | 160 break; |
161 | |
162 case ivSetDVDTitle: | |
163 guiInfo.Track = iparam; | |
164 guiInfo.Chapter = 1; | |
165 guiInfo.Angle = 1; | |
35773 | 166 uiEvent(ivPlayDVD, 0); |
35771 | 167 break; |
168 | |
169 case evPlayDVD: | |
170 guiInfo.Chapter = 1; | |
171 guiInfo.Angle = 1; | |
172 | |
173 case ivPlayDVD: | |
174 guiInfo.StreamType = STREAMTYPE_DVD; | |
175 goto play; | |
176 | |
177 #endif | |
178 case evPlay: | |
179 case evPlaySwitchToPause: | |
180 play: | |
181 | |
35791 | 182 if (guiInfo.Playing != GUI_PAUSE) { |
35792 | 183 MediumPrepare(guiInfo.StreamType); |
35771 | 184 |
35792 | 185 switch (guiInfo.StreamType) { |
186 case STREAMTYPE_FILE: | |
187 case STREAMTYPE_STREAM: | |
188 case STREAMTYPE_PLAYLIST: | |
35771 | 189 |
35792 | 190 if (!guiInfo.Track) |
191 guiInfo.Track = 1; | |
35771 | 192 |
35792 | 193 guiInfo.NewPlay = GUI_FILE_NEW; |
194 guiInfo.PlaylistNext = !guiInfo.Playing; | |
35791 | 195 |
35792 | 196 break; |
35771 | 197 |
35792 | 198 case STREAMTYPE_CDDA: |
199 case STREAMTYPE_VCD: | |
200 case STREAMTYPE_DVD: | |
35771 | 201 |
202 if (!guiInfo.Track) | |
35793 | 203 guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); |
35771 | 204 |
205 guiInfo.NewPlay = GUI_FILE_SAME; | |
206 | |
35792 | 207 break; |
208 } | |
35791 | 209 } |
35771 | 210 |
211 uiPlay(); | |
212 break; | |
213 | |
214 case evPause: | |
215 case evPauseSwitchToPlay: | |
216 uiPause(); | |
217 break; | |
218 | |
219 case evStop: | |
220 guiInfo.Playing = GUI_STOP; | |
221 uiState(); | |
222 break; | |
223 | |
224 case evLoadPlay: | |
225 uiLoadPlay = True; | |
226 | |
227 // guiInfo.StreamType=STREAMTYPE_FILE; | |
228 case evLoad: | |
229 gtkShow(evLoad, NULL); | |
230 break; | |
231 | |
232 case evLoadSubtitle: | |
233 gtkShow(evLoadSubtitle, NULL); | |
234 break; | |
235 | |
236 case evDropSubtitle: | |
237 nfree(guiInfo.SubtitleFilename); | |
238 mplayerLoadSubtitle(NULL); | |
239 break; | |
240 | |
241 case evLoadAudioFile: | |
242 gtkShow(evLoadAudioFile, NULL); | |
243 break; | |
244 | |
245 case evPrev: | |
246 uiPrev(); | |
247 break; | |
248 | |
249 case evNext: | |
250 uiNext(); | |
251 break; | |
252 | |
253 case evPlaylist: | |
254 gtkShow(evPlaylist, NULL); | |
255 break; | |
256 | |
257 case evSkinBrowser: | |
258 gtkShow(evSkinBrowser, skinName); | |
259 break; | |
260 | |
261 case evAbout: | |
262 gtkShow(evAbout, NULL); | |
263 break; | |
264 | |
265 case evPreferences: | |
266 gtkShow(evPreferences, NULL); | |
267 break; | |
268 | |
269 case evEqualizer: | |
270 gtkShow(evEqualizer, NULL); | |
271 break; | |
272 | |
273 case evForward10min: | |
274 uiRelSeek(600); | |
275 break; | |
276 | |
277 case evBackward10min: | |
278 uiRelSeek(-600); | |
279 break; | |
280 | |
281 case evForward1min: | |
282 uiRelSeek(60); | |
283 break; | |
284 | |
285 case evBackward1min: | |
286 uiRelSeek(-60); | |
287 break; | |
288 | |
289 case evForward10sec: | |
290 uiRelSeek(10); | |
291 break; | |
292 | |
293 case evBackward10sec: | |
294 uiRelSeek(-10); | |
295 break; | |
296 | |
297 case evSetMoviePosition: | |
298 uiAbsSeek(param); | |
299 break; | |
300 | |
301 case evIncVolume: | |
302 vo_x11_putkey(wsGrayMul); | |
303 break; | |
304 | |
305 case evDecVolume: | |
306 vo_x11_putkey(wsGrayDiv); | |
307 break; | |
308 | |
309 case evMute: | |
310 mixer_mute(mixer); | |
311 break; | |
312 | |
313 case evSetVolume: | |
314 guiInfo.Volume = param; | |
315 { | |
316 float l = guiInfo.Volume * ((100.0 - guiInfo.Balance) / 50.0); | |
317 float r = guiInfo.Volume * ((guiInfo.Balance) / 50.0); | |
318 mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); | |
319 } | |
320 | |
321 if (osd_level) { | |
322 osd_visible = (GetTimerMS() + 1000) | 1; | |
323 vo_osd_progbar_type = OSD_VOLUME; | |
324 vo_osd_progbar_value = ((guiInfo.Volume) * 256.0) / 100.0; | |
325 vo_osd_changed(OSDTYPE_PROGBAR); | |
326 } | |
327 | |
328 break; | |
329 | |
330 case evSetBalance: | |
331 guiInfo.Balance = param; | |
332 mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 | |
333 osd = osd_level; | |
334 osd_level = 0; | |
35773 | 335 uiEvent(evSetVolume, guiInfo.Volume); |
35771 | 336 osd_level = osd; |
337 | |
338 if (osd_level) { | |
339 osd_visible = (GetTimerMS() + 1000) | 1; | |
340 vo_osd_progbar_type = OSD_BALANCE; | |
341 vo_osd_progbar_value = ((guiInfo.Balance) * 256.0) / 100.0; | |
342 vo_osd_changed(OSDTYPE_PROGBAR); | |
343 } | |
344 | |
345 break; | |
346 | |
347 case evMenu: | |
348 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse | |
349 * { pointer and cursor keys work | |
350 * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
351 * uiMenuShow( 0,0 ); they do with normal menus. | |
352 * } | |
353 * else*/gtkShow(ivShowPopUpMenu, NULL); | |
354 break; | |
355 | |
356 case evIconify: | |
357 | |
358 switch (iparam) { | |
359 case 0: | |
360 wsWindowIconify(&guiApp.mainWindow); | |
361 break; | |
362 | |
363 case 1: | |
364 wsWindowIconify(&guiApp.videoWindow); | |
365 break; | |
366 } | |
367 | |
368 break; | |
369 | |
370 case evHalfSize: | |
371 | |
372 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
373 if (guiApp.videoWindow.isFullScreen) { | |
374 uiFullScreen(); | |
375 } | |
376 | |
377 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); | |
378 btnSet(evFullScreen, btnReleased); | |
379 } | |
380 | |
381 break; | |
382 | |
383 case evDoubleSize: | |
384 | |
385 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
386 if (guiApp.videoWindow.isFullScreen) { | |
387 uiFullScreen(); | |
388 } | |
389 | |
390 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); | |
391 wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
392 btnSet(evFullScreen, btnReleased); | |
393 } | |
394 | |
395 break; | |
396 | |
397 case evNormalSize: | |
398 | |
399 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
400 if (guiApp.videoWindow.isFullScreen) { | |
401 uiFullScreen(); | |
402 } | |
403 | |
404 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); | |
405 btnSet(evFullScreen, btnReleased); | |
406 break; | |
407 } else if (!guiApp.videoWindow.isFullScreen) | |
408 break; | |
409 | |
410 case evFullScreen: | |
411 | |
412 if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { | |
413 uiFullScreen(); | |
414 | |
415 if (!guiApp.videoWindow.isFullScreen) | |
416 wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); | |
417 } | |
418 | |
419 if (guiApp.videoWindow.isFullScreen) | |
420 btnSet(evFullScreen, btnPressed); | |
421 else | |
422 btnSet(evFullScreen, btnReleased); | |
423 | |
424 break; | |
425 | |
426 case evSetAspect: | |
427 | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
428 if (guiInfo.VideoAspect == 0) |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
429 guiInfo.VideoAspect = guiInfo.sh_video->aspect; |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
430 |
35771 | 431 switch (iparam) { |
432 case 2: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
433 aspect = 16.0f / 9.0f; |
35771 | 434 break; |
435 | |
436 case 3: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
437 aspect = 4.0f / 3.0f; |
35771 | 438 break; |
439 | |
440 case 4: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
441 aspect = 2.35; |
35771 | 442 break; |
443 | |
444 case 1: | |
445 default: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
446 aspect = guiInfo.VideoAspect; |
35771 | 447 } |
448 | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
449 snprintf(cmd, sizeof(cmd), "switch_ratio %f", aspect); |
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
450 mp_input_queue_cmd(mp_input_parse_cmd(cmd)); |
35771 | 451 |
452 break; | |
453 | |
454 /* timer events */ | |
455 case ivRedraw: | |
456 { | |
35775 | 457 unsigned int now = GetTimerMS(); |
35771 | 458 |
459 if ((now > last_redraw_time) && | |
460 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
461 !uiPlaybarFade && (iparam == 0)) | |
462 break; | |
463 | |
464 last_redraw_time = now; | |
465 } | |
466 uiMainRender = True; | |
467 wsWindowRedraw(&guiApp.mainWindow); | |
468 wsWindowRedraw(&guiApp.playbarWindow); | |
469 break; | |
470 | |
471 /* system events */ | |
472 case evNone: | |
35773 | 473 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); |
35771 | 474 break; |
475 | |
476 default: | |
35773 | 477 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); |
35771 | 478 break; |
479 } | |
480 } | |
23077 | 481 |
35437 | 482 /** |
483 * @brief Switch video window fullscreen mode. | |
484 * | |
485 * Switch normal video to fullscreen and fullscreen video to normal. | |
486 */ | |
33555 | 487 void uiFullScreen(void) |
23077 | 488 { |
33960 | 489 if (!guiInfo.VideoWindow) |
32881 | 490 return; |
491 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
492 wsWindowFullscreen(&guiApp.videoWindow); |
23077 | 493 |
34697 | 494 vo_fs = guiApp.videoWindow.isFullScreen; |
23077 | 495 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
496 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 497 |
33555 | 498 if (guiApp.menuIsPresent) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
499 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
23077 | 500 } |
501 | |
35437 | 502 /** |
503 * @brief Switch to play mode. | |
504 */ | |
33555 | 505 void uiPlay(void) |
23077 | 506 { |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
507 if (guiInfo.Playing == GUI_PLAY) |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
508 return; |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
509 |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
510 if (guiInfo.StreamType != STREAMTYPE_CDDA && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
511 guiInfo.StreamType != STREAMTYPE_VCD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
512 guiInfo.StreamType != STREAMTYPE_DVD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
513 (!guiInfo.Filename || (guiInfo.Filename[0] == 0))) |
32881 | 514 return; |
23077 | 515 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
516 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 517 uiPause(); |
32881 | 518 return; |
519 } | |
520 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
521 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
23077 | 522 } |
523 | |
35437 | 524 /** |
525 * @brief Switch to pause mode. | |
526 */ | |
33555 | 527 void uiPause(void) |
23077 | 528 { |
33555 | 529 if (!guiInfo.Playing) |
32881 | 530 return; |
531 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
532 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 533 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
35433 | 534 |
35432 | 535 if (cmd) { |
35433 | 536 cmd->id = MP_CMD_PAUSE; |
537 cmd->name = strdup("pause"); | |
538 mp_input_queue_cmd(cmd); | |
35432 | 539 } |
32881 | 540 } else |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
541 guiInfo.Playing = GUI_PLAY; |
23077 | 542 } |
543 | |
35437 | 544 /** |
545 * @brief Adjust GUI items to reflect current state (i.e. current playing mode). | |
546 */ | |
33555 | 547 void uiState(void) |
32881 | 548 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
549 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 550 btnSet(evPlaySwitchToPause, btnReleased); |
551 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 552 } else { |
35434 | 553 btnSet(evPauseSwitchToPlay, btnReleased); |
33978 | 554 btnSet(evPlaySwitchToPause, btnDisabled); |
32881 | 555 } |
23077 | 556 } |
557 | |
35437 | 558 /** |
559 * @brief Seek new playback position. | |
560 * | |
35438 | 561 * The new position is a relative one. |
35437 | 562 * |
563 * @param sec seconds to seek (either forward (> 0) or backward (< 0)) | |
564 */ | |
33555 | 565 void uiRelSeek(float sec) |
32881 | 566 { |
32971 | 567 rel_seek_secs = sec; |
32881 | 568 abs_seek_pos = 0; |
569 } | |
570 | |
35437 | 571 /** |
572 * @brief Seek new playback position. | |
573 * | |
35438 | 574 * The new position is an absolute one. |
35437 | 575 * |
576 * @param percent percentage of playback time to position to | |
577 */ | |
33555 | 578 void uiAbsSeek(float percent) |
32881 | 579 { |
32971 | 580 rel_seek_secs = percent / 100.0; |
35431 | 581 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; |
23077 | 582 } |
583 | |
35437 | 584 /** |
585 * @brief Change to a different skin. | |
586 * | |
587 * @param name name of the skin to change to | |
588 */ | |
33555 | 589 void uiChangeSkin(char *name) |
23077 | 590 { |
35799 | 591 int was_menu, was_playbar; |
32881 | 592 |
35799 | 593 was_menu = guiApp.menuIsPresent; |
594 was_playbar = guiApp.playbarIsPresent; | |
32881 | 595 |
35493 | 596 mainVisible = False; |
32881 | 597 |
32893 | 598 if (skinRead(name) != 0) { |
599 if (skinRead(skinName) != 0) { | |
35801
98693cc5df48
Exit GUI if we can't return to the skin we started with.
ib
parents:
35800
diff
changeset
|
600 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_SKIN_SKINCFG_SkinCfgError, skinName); |
98693cc5df48
Exit GUI if we can't return to the skin we started with.
ib
parents:
35800
diff
changeset
|
601 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32893 | 602 } |
32881 | 603 } |
604 | |
35800 | 605 /* reload main window (must be first!) */ |
23077 | 606 |
35800 | 607 uiMainDone(); |
608 uiMainInit(); | |
32881 | 609 |
35800 | 610 wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); |
611 mainVisible = True; | |
23077 | 612 |
35805 | 613 /* adjust video window */ |
23077 | 614 |
35805 | 615 if (guiApp.video.Bitmap.Image) { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
616 wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); |
35805 | 617 wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); |
618 } | |
32881 | 619 |
35805 | 620 if (!guiInfo.Playing) { |
621 if (!guiApp.videoWindow.isFullScreen) { | |
35806 | 622 wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); |
623 wsWindowMove(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
624 } | |
32881 | 625 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
626 wsWindowRedraw(&guiApp.videoWindow); |
35805 | 627 } |
32881 | 628 |
34684 | 629 /* reload playbar */ |
32881 | 630 |
35799 | 631 if (was_playbar) |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35795
diff
changeset
|
632 uiPlaybarDone(); |
32881 | 633 |
33555 | 634 uiPlaybarInit(); |
23077 | 635 |
35800 | 636 /* reload menu window */ |
637 | |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
638 if (was_menu) |
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
639 uiMenuDone(); |
32881 | 640 |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
641 uiMenuInit(); |
35800 | 642 |
643 /* */ | |
32881 | 644 |
33555 | 645 btnModify(evSetVolume, guiInfo.Volume); |
646 btnModify(evSetBalance, guiInfo.Balance); | |
647 btnModify(evSetMoviePosition, guiInfo.Position); | |
34697 | 648 btnSet(evFullScreen, (guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 649 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
650 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
651 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 652 } |
653 | |
35437 | 654 /** |
35452 | 655 * @brief Set the file to be played. |
35437 | 656 * |
657 * @param dir directory (optional, else NULL) | |
658 * @param name filename | |
659 * @param type stream type of the file | |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
660 * |
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
661 * @note All #guiInfo members associated with the file will be cleared. |
35437 | 662 */ |
35968 | 663 void uiSetFile(const char *dir, const char *name, int type) |
32881 | 664 { |
665 if (!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
666 setdup(&guiInfo.Filename, name); |
32881 | 667 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
668 setddup(&guiInfo.Filename, dir, name); |
23077 | 669 |
34064 | 670 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
671 |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
672 if (type != SAME_STREAMTYPE) { |
34400 | 673 guiInfo.StreamType = type; |
35568 | 674 uiUnsetMedia(False); |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
675 } |
23077 | 676 } |
677 | |
35437 | 678 /** |
35453 | 679 * @brief Unset the file being played. |
680 */ | |
681 void uiUnsetFile(void) | |
682 { | |
683 uiSetFile(NULL, NULL, STREAMTYPE_DUMMY); | |
684 } | |
685 | |
686 /** | |
35562 | 687 * @brief Unset media information. |
35568 | 688 * |
689 * @param totals whether to unset number of chapters and angles (#True) or | |
690 * just track, chapter and angle (#False) as well | |
35562 | 691 */ |
35568 | 692 void uiUnsetMedia(int totals) |
35562 | 693 { |
694 guiInfo.VideoWidth = 0; | |
695 guiInfo.VideoHeight = 0; | |
696 guiInfo.AudioChannels = 0; | |
697 guiInfo.RunningTime = 0; | |
35568 | 698 |
699 if (totals) { | |
700 guiInfo.Chapters = 0; | |
701 guiInfo.Angles = 0; | |
702 } else { | |
35569 | 703 guiInfo.Track = 0; |
704 guiInfo.Chapter = 0; | |
705 guiInfo.Angle = 0; | |
35568 | 706 } |
35562 | 707 |
708 nfree(guiInfo.CodecName); | |
709 nfree(guiInfo.AudioFilename); | |
710 nfree(guiInfo.SubtitleFilename); | |
711 } | |
712 | |
713 /** | |
35437 | 714 * @brief Set file to be played to current playlist entry. |
715 */ | |
33555 | 716 void uiCurr(void) |
23077 | 717 { |
32881 | 718 plItem *curr; |
23077 | 719 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
720 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 721 return; |
23077 | 722 |
33555 | 723 switch (guiInfo.StreamType) { |
34387 | 724 case STREAMTYPE_CDDA: |
34077 | 725 case STREAMTYPE_VCD: |
726 case STREAMTYPE_DVD: | |
35433 | 727 |
32881 | 728 break; |
729 | |
730 default: | |
731 | |
34663 | 732 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
32881 | 733 |
734 if (curr) { | |
35452 | 735 uiSetFile(curr->path, curr->name, STREAMTYPE_FILE); |
35493 | 736 guiInfo.PlaylistNext = False; |
35485 | 737 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, curr); |
32881 | 738 break; |
739 } | |
740 | |
741 return; | |
742 } | |
743 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
744 if (guiInfo.Playing == GUI_PLAY) |
35773 | 745 uiEvent(evPlay, 0); |
23077 | 746 } |
747 | |
35437 | 748 /** |
749 * @brief Switch to previous playback track. | |
750 */ | |
33555 | 751 void uiPrev(void) |
23077 | 752 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
753 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
754 plItem *prev = NULL; |
32881 | 755 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
756 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 757 return; |
758 | |
33555 | 759 switch (guiInfo.StreamType) { |
34387 | 760 case STREAMTYPE_CDDA: |
35426 | 761 |
34387 | 762 if (--guiInfo.Track == 0) { |
763 guiInfo.Track = 1; | |
35493 | 764 stop = True; |
34387 | 765 } |
35426 | 766 |
34387 | 767 break; |
768 | |
34077 | 769 case STREAMTYPE_VCD: |
35426 | 770 |
34077 | 771 if (--guiInfo.Track == 1) { |
772 guiInfo.Track = 2; | |
35493 | 773 stop = True; |
34077 | 774 } |
35426 | 775 |
34077 | 776 break; |
777 | |
32881 | 778 case STREAMTYPE_DVD: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
779 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
780 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
781 guiInfo.Chapter = 1; |
32881 | 782 |
35428 | 783 if (--guiInfo.Track == 0) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
784 guiInfo.Track = 1; |
35493 | 785 stop = True; |
32881 | 786 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
787 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
788 unset = False; |
32881 | 789 |
790 break; | |
791 | |
792 default: | |
793 | |
34663 | 794 prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); |
32881 | 795 |
796 if (prev) { | |
35452 | 797 uiSetFile(prev->path, prev->name, STREAMTYPE_FILE); |
35500 | 798 guiInfo.PlaylistNext = !guiInfo.Playing; |
35458 | 799 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, prev); |
32881 | 800 break; |
801 } | |
802 | |
803 return; | |
804 } | |
805 | |
806 if (stop) | |
35773 | 807 uiEvent(evStop, 0); |
32881 | 808 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
809 if (guiInfo.Playing == GUI_PLAY) |
35773 | 810 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
811 else if (!stop && !prev && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
812 uiUnsetMedia(True); |
23077 | 813 } |
814 | |
35437 | 815 /** |
816 * @brief Switch to next playback track. | |
817 */ | |
33555 | 818 void uiNext(void) |
23077 | 819 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
820 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
821 plItem *next = NULL; |
23077 | 822 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
823 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 824 return; |
825 | |
33555 | 826 switch (guiInfo.StreamType) { |
34387 | 827 case STREAMTYPE_CDDA: |
35425 | 828 case STREAMTYPE_VCD: |
34387 | 829 |
830 if (++guiInfo.Track > guiInfo.Tracks) { | |
831 guiInfo.Track = guiInfo.Tracks; | |
35493 | 832 stop = True; |
34387 | 833 } |
834 | |
835 break; | |
836 | |
32881 | 837 case STREAMTYPE_DVD: |
838 | |
35570 | 839 if (guiInfo.Chapter++ >= guiInfo.Chapters) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
840 guiInfo.Chapter = 1; |
32881 | 841 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
842 if (++guiInfo.Track > guiInfo.Tracks) { |
35561 | 843 guiInfo.Track = guiInfo.Tracks; |
35560
1a2200a93ea8
Make DVD stop if manually advancing beyond last chapter of last track.
ib
parents:
35528
diff
changeset
|
844 guiInfo.Chapter = guiInfo.Chapters; |
35493 | 845 stop = True; |
32881 | 846 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
847 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
848 unset = False; |
32881 | 849 |
850 break; | |
851 | |
852 default: | |
853 | |
34663 | 854 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
32881 | 855 |
856 if (next) { | |
35452 | 857 uiSetFile(next->path, next->name, STREAMTYPE_FILE); |
35500 | 858 guiInfo.PlaylistNext = !guiInfo.Playing; |
35458 | 859 guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, next); |
32881 | 860 break; |
861 } | |
862 | |
863 return; | |
864 } | |
865 | |
866 if (stop) | |
35773 | 867 uiEvent(evStop, 0); |
32881 | 868 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
869 if (guiInfo.Playing == GUI_PLAY) |
35773 | 870 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
871 else if (!stop && !next && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
872 uiUnsetMedia(True); |
23077 | 873 } |