Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 33894:b2e63fe7fe17
Remove needless guiInfo member FilenameChanged.
Use existing member NewPlay for this, because FilenameChanged
and NewPlay == GUI_FILE_NEW mean the same.
| author | ib |
|---|---|
| date | Fri, 12 Aug 2011 14:09:36 +0000 |
| parents | c51e44dd38e2 |
| children | e0d211c62cf7 |
| rev | line source |
|---|---|
| 23077 | 1 /* |
| 23079 | 2 * MPlayer GUI for Win32 |
| 3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
| 4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
| 5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
| 6 * | |
| 7 * This file is part of MPlayer. | |
| 8 * | |
| 9 * MPlayer is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; either version 2 of the License, or | |
| 12 * (at your option) any later version. | |
| 13 * | |
| 14 * MPlayer is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 26457 | 19 * You should have received a copy of the GNU General Public License along |
| 20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
| 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 23079 | 22 */ |
| 23077 | 23 |
| 24 #include <windows.h> | |
| 33358 | 25 |
| 26 #if defined(__CYGWIN__) | |
| 27 #define _beginthreadex CreateThread | |
| 28 #else | |
| 29 #include <process.h> | |
| 30 #endif | |
| 31 | |
| 30901 | 32 #include "path.h" |
|
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
33 #include "gui/interface.h" |
|
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "m_option.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mixer.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "mp_msg.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "help_mp.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "codec-cfg.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "stream/stream.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "libmpdemux/demuxer.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "libmpdemux/stheader.h" |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
42 #ifdef CONFIG_DVDREAD |
|
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
43 #include "stream/stream_dvd.h" |
| 23077 | 44 #endif |
|
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
45 #include "input/input.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
46 #include "libvo/video_out.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
47 #include "libao2/audio_out.h" |
|
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
48 #include "access_mpcontext.h" |
| 30558 | 49 #include "libmpcodecs/vd.h" |
|
31425
2392ad3cec9c
Move af_cfg extern variable declaration to dec_audio.h.
diego
parents:
31312
diff
changeset
|
50 #include "libmpcodecs/dec_audio.h" |
| 33761 | 51 #include "gui/ui/actions.h" |
| 33557 | 52 #include "gui/ui/gmplayer.h" |
| 33770 | 53 #include "gui/util/mem.h" |
| 33761 | 54 #include "gui/util/list.h" |
| 55 #include "gui/util/string.h" | |
| 30558 | 56 #include "mp_core.h" |
| 32093 | 57 #include "mpcommon.h" |
| 23077 | 58 #include "gui.h" |
| 59 #include "dialogs.h" | |
|
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
60 #ifdef CONFIG_LIBCDIO |
| 23077 | 61 #include <cdio/cdio.h> |
| 62 #endif | |
| 63 | |
| 64 int guiWinID = 0; | |
| 65 | |
| 66 char *skinName = NULL; | |
| 67 char *codecname = NULL; | |
| 33555 | 68 int uiGotoTheNext = 1; |
| 23077 | 69 static gui_t *mygui = NULL; |
| 70 static int update_subwindow(void); | |
| 71 static RECT old_rect; | |
| 72 static DWORD style; | |
| 24992 | 73 static HANDLE hThread; |
| 74 static unsigned threadId; | |
|
25765
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
75 const ao_functions_t *audio_out = NULL; |
|
304fc0bbefe1
audio_out / video_out structs should be treated as const
reimar
parents:
24992
diff
changeset
|
76 const vo_functions_t *video_out = NULL; |
| 23077 | 77 mixer_t *mixer = NULL; |
| 78 | |
| 79 /* test for playlist files, no need to specify -playlist on the commandline. | |
| 80 * add any conceivable playlist extensions here. | |
| 81 * - Erik | |
| 82 */ | |
| 83 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear) | |
| 84 { | |
| 85 if(clear) | |
| 86 mygui->playlist->clear_playlist(mygui->playlist); | |
| 87 | |
| 88 if(strstr(file, ".m3u") || strstr(file, ".pls")) | |
| 89 { | |
| 90 playtree = parse_playlist_file(file); | |
| 33752 | 91 guiPlaylistAdd(playtree, mconfig); |
| 23077 | 92 return 1; |
| 93 } | |
| 94 return 0; | |
| 95 } | |
| 96 | |
| 97 /* this function gets called by the gui to update mplayer */ | |
| 98 static void guiSetEvent(int event) | |
| 99 { | |
| 33555 | 100 if(guiInfo.mpcontext) |
| 101 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
| 23077 | 102 |
| 103 switch(event) | |
| 104 { | |
| 105 case evPlay: | |
| 106 case evPlaySwitchToPause: | |
|
23148
71efd1fc20c8
add missing case value, fixes functionality when using some skins.
vayne
parents:
23147
diff
changeset
|
107 case evPauseSwitchToPlay: |
| 33555 | 108 uiPlay(); |
| 23077 | 109 break; |
| 110 case evPause: | |
| 33555 | 111 uiPause(); |
| 23077 | 112 break; |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
113 #ifdef CONFIG_DVDREAD |
| 23077 | 114 case evPlayDVD: |
| 115 { | |
| 116 static char dvdname[MAX_PATH]; | |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
117 guiInfo.Track = dvd_title; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
118 guiInfo.Chapter = dvd_chapter; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
119 guiInfo.Angle = dvd_angle; |
| 33890 | 120 guiInfo.NewPlay = GUI_FILE_SAME; |
| 23077 | 121 |
| 33555 | 122 uiSetFileName(NULL, dvd_device, STREAMTYPE_DVD); |
| 23077 | 123 dvdname[0] = 0; |
| 124 strcat(dvdname, "DVD Movie"); | |
| 125 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
| 126 capitalize(dvdname); | |
| 127 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname); | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
128 gui(GUI_PREPARE, (void *) STREAMTYPE_DVD); |
| 23077 | 129 mygui->playlist->clear_playlist(mygui->playlist); |
| 130 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
| 131 mygui->startplay(mygui); | |
| 132 break; | |
| 133 } | |
| 134 #endif | |
|
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
135 #ifdef CONFIG_LIBCDIO |
| 23077 | 136 case evPlayCD: |
| 137 { | |
| 138 int i; | |
| 139 char track[10]; | |
| 140 char trackname[10]; | |
| 141 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
| 142 track_t i_tracks; | |
| 143 | |
| 144 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
| 145 i_tracks = cdio_get_num_tracks(p_cdio); | |
| 146 | |
| 147 mygui->playlist->clear_playlist(mygui->playlist); | |
| 148 for(i=0;i<i_tracks;i++) | |
| 149 { | |
| 150 sprintf(track, "cdda://%d", i+1); | |
| 151 sprintf(trackname, "Track %d", i+1); | |
| 152 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
| 153 } | |
| 154 cdio_destroy(p_cdio); | |
| 155 mygui->startplay(mygui); | |
| 156 break; | |
| 157 } | |
| 158 #endif | |
| 159 case evFullScreen: | |
| 160 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
| 161 break; | |
| 162 case evExit: | |
| 163 { | |
| 164 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
| 165 this should be the only safe way to quit */ | |
| 166 mygui->activewidget = NULL; | |
| 167 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
| 168 break; | |
| 169 } | |
| 170 case evStop: | |
| 33555 | 171 if(guiInfo.Playing) |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
172 gui(GUI_SET_STATE, (void *) GUI_STOP); |
| 23077 | 173 break; |
| 174 case evSetMoviePosition: | |
| 175 { | |
| 33555 | 176 rel_seek_secs = guiInfo.Position / 100.0f; |
| 23077 | 177 abs_seek_pos = 3; |
| 178 break; | |
| 179 } | |
| 180 case evForward10sec: | |
| 181 { | |
| 182 rel_seek_secs = 10.0f; | |
| 183 abs_seek_pos = 0; | |
| 184 break; | |
| 185 } | |
| 186 case evBackward10sec: | |
| 187 { | |
| 188 rel_seek_secs = -10.0f; | |
| 189 abs_seek_pos = 0; | |
| 190 break; | |
| 191 } | |
| 192 case evSetBalance: | |
| 193 case evSetVolume: | |
| 194 { | |
| 195 float l,r; | |
| 196 | |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
197 if (guiInfo.Playing == GUI_STOP) |
| 23077 | 198 break; |
| 199 | |
| 33555 | 200 if (guiInfo.Balance == 50.0f) |
| 201 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
| 23077 | 202 |
| 33555 | 203 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
| 204 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
| 23077 | 205 |
| 33555 | 206 if (l > guiInfo.Volume) l=guiInfo.Volume; |
| 207 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
| 23077 | 208 mixer_setvolume(mixer, l, r); |
| 209 /* Check for balance support on mixer - there is a better way ?? */ | |
| 210 if (r != l) | |
| 211 { | |
| 212 mixer_getvolume(mixer, &l, &r); | |
| 213 if (r == l) | |
| 214 { | |
| 215 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
| 33555 | 216 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
| 217 guiInfo.Balance = 50.0f; | |
| 23077 | 218 } |
| 219 } | |
| 220 break; | |
| 221 } | |
| 222 case evMute: | |
| 223 { | |
| 224 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
| 225 cmd->id=MP_CMD_MUTE; | |
| 226 cmd->name=strdup("mute"); | |
| 227 mp_input_queue_cmd(cmd); | |
| 228 break; | |
| 229 } | |
| 230 case evDropFile: | |
| 231 case evLoadPlay: | |
| 232 { | |
| 33555 | 233 switch(guiInfo.StreamType) |
| 23077 | 234 { |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
235 #ifdef CONFIG_DVDREAD |
| 23077 | 236 case STREAMTYPE_DVD: |
| 237 { | |
| 33890 | 238 guiInfo.NewPlay = GUI_FILE_SAME; |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
239 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
| 23077 | 240 break; |
| 241 } | |
|
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
242 #endif |
| 23077 | 243 default: |
| 244 { | |
| 33890 | 245 guiInfo.NewPlay = GUI_FILE_NEW; |
| 23077 | 246 update_playlistwindow(); |
| 33555 | 247 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
248 gui(GUI_SET_STATE, (void *) GUI_STOP); |
|
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
249 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
| 23077 | 250 break; |
| 251 } | |
| 252 } | |
| 253 break; | |
| 254 } | |
| 255 case evNext: | |
| 33555 | 256 uiNext(); |
| 23077 | 257 break; |
| 258 case evPrev: | |
| 33555 | 259 uiPrev(); |
| 23077 | 260 break; |
| 261 } | |
| 262 } | |
| 263 | |
| 33555 | 264 void uiPlay( void ) |
| 23077 | 265 { |
| 33555 | 266 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
| 23077 | 267 return; |
| 268 | |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
269 if(guiInfo.Playing > GUI_STOP) |
| 23077 | 270 { |
| 33555 | 271 uiPause(); |
| 23077 | 272 return; |
| 273 } | |
| 33890 | 274 guiInfo.NewPlay = GUI_FILE_NEW; |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
275 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
| 23077 | 276 } |
| 277 | |
| 33555 | 278 void uiPause( void ) |
| 23077 | 279 { |
| 33555 | 280 if(!guiInfo.Playing) return; |
| 23077 | 281 |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
282 if(guiInfo.Playing == GUI_PLAY) |
| 23077 | 283 { |
| 284 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
| 285 cmd->id=MP_CMD_PAUSE; | |
| 286 cmd->name=strdup("pause"); | |
| 287 mp_input_queue_cmd(cmd); | |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
288 } else guiInfo.Playing = GUI_PLAY; |
| 23077 | 289 } |
| 290 | |
| 33555 | 291 void uiNext(void) |
| 23077 | 292 { |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
293 if(guiInfo.Playing == GUI_PAUSE) return; |
| 33555 | 294 switch(guiInfo.StreamType) |
| 23077 | 295 { |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
296 #ifdef CONFIG_DVDREAD |
| 23077 | 297 case STREAMTYPE_DVD: |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
298 if(guiInfo.Chapter == (guiInfo.Chapters - 1)) |
| 23077 | 299 return; |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
300 guiInfo.Chapter++; |
| 23077 | 301 break; |
| 302 #endif | |
| 303 default: | |
| 304 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
| 305 return; | |
| 33555 | 306 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
| 23077 | 307 STREAMTYPE_STREAM); |
| 308 break; | |
| 309 } | |
| 310 mygui->startplay(mygui); | |
| 311 } | |
| 312 | |
| 33555 | 313 void uiPrev(void) |
| 23077 | 314 { |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
315 if(guiInfo.Playing == GUI_PAUSE) return; |
| 33555 | 316 switch(guiInfo.StreamType) |
| 23077 | 317 { |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
318 #ifdef CONFIG_DVDREAD |
| 23077 | 319 case STREAMTYPE_DVD: |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
320 if(guiInfo.Chapter == 1) |
| 23077 | 321 return; |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
322 guiInfo.Chapter--; |
| 23077 | 323 break; |
| 324 #endif | |
| 325 default: | |
| 326 if(mygui->playlist->current == 0) | |
| 327 return; | |
| 33555 | 328 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
| 23077 | 329 STREAMTYPE_STREAM); |
| 330 break; | |
| 331 } | |
| 332 mygui->startplay(mygui); | |
| 333 } | |
| 334 | |
| 33555 | 335 void uiSetFileName(char *dir, char *name, int type) |
| 23077 | 336 { |
| 337 if(!name) return; | |
| 338 if(!dir) | |
|
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
339 setdup(&guiInfo.Filename, name); |
| 23077 | 340 else |
|
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
341 setddup(&guiInfo.Filename, dir, name); |
| 23077 | 342 |
| 33555 | 343 guiInfo.StreamType = type; |
| 33770 | 344 nfree(guiInfo.AudioFile); |
| 345 nfree(guiInfo.Subtitlename); | |
| 23077 | 346 } |
| 347 | |
| 33555 | 348 void uiFullScreen( void ) |
| 23077 | 349 { |
| 33555 | 350 if(!guiInfo.sh_video) return; |
| 23077 | 351 |
| 352 if(sub_window) | |
| 353 { | |
| 354 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
| 355 GetWindowRect(mygui->subwindow, &old_rect); | |
| 356 | |
| 357 if(fullscreen) | |
| 358 { | |
| 359 fullscreen = 0; | |
| 360 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
| 361 } else { | |
| 362 fullscreen = 1; | |
| 363 style = WS_VISIBLE | WS_POPUP; | |
| 364 } | |
| 365 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
| 366 update_subwindow(); | |
| 367 } | |
| 368 video_out->control(VOCTRL_FULLSCREEN, 0); | |
| 369 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
| 370 } | |
| 371 | |
| 24992 | 372 static unsigned __stdcall GuiThread(void* param) |
| 23077 | 373 { |
| 374 MSG msg; | |
| 375 | |
| 376 if(!skinName) skinName = strdup("Blue"); | |
| 33781 | 377 if(!mygui) mygui = create_gui(get_path("skins"), guiSetEvent); |
| 30558 | 378 if(!mygui) exit_player(EXIT_ERROR); |
| 23077 | 379 |
| 380 if(autosync && autosync != gtkAutoSync) | |
| 381 { | |
| 382 gtkAutoSyncOn = 1; | |
| 383 gtkAutoSync = autosync; | |
| 384 } | |
| 385 | |
| 24992 | 386 while(GetMessage(&msg, NULL, 0, 0)) |
| 23077 | 387 { |
| 388 TranslateMessage(&msg); | |
| 389 DispatchMessage(&msg); | |
| 390 } | |
| 23078 | 391 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
| 23077 | 392 fflush(stderr); |
| 393 return 0; | |
| 394 } | |
| 395 | |
| 396 void guiInit(void) | |
| 397 { | |
| 33555 | 398 memset(&guiInfo, 0, sizeof(guiInfo)); |
| 23077 | 399 /* Create The gui thread */ |
| 400 if (!mygui) | |
| 401 { | |
| 33358 | 402 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
| 23077 | 403 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
| 404 } | |
| 405 | |
| 406 /* Wait until the gui is created */ | |
| 407 while(!mygui) Sleep(100); | |
| 23078 | 408 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
| 23077 | 409 } |
| 410 | |
| 411 void guiDone(void) | |
| 412 { | |
| 413 if(mygui) | |
| 414 { | |
| 415 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
| 416 fflush(stderr); | |
| 24992 | 417 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
| 418 WaitForSingleObject(hThread, INFINITE); | |
| 419 CloseHandle(hThread); | |
| 23077 | 420 mygui->uninit(mygui); |
| 33770 | 421 nfree(mygui); |
| 23077 | 422 } |
| 423 /* Remove tray icon */ | |
| 424 Shell_NotifyIcon(NIM_DELETE, &nid); | |
| 425 cfg_write(); | |
| 426 } | |
| 427 | |
| 428 /* this function gets called by mplayer to update the gui */ | |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
429 int gui(int what, void *data) |
| 23077 | 430 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
431 stream_t *stream = data; |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
432 #ifdef CONFIG_DVDREAD |
| 33730 | 433 dvd_priv_t *dvdp; |
| 23077 | 434 #endif |
| 435 if(!mygui || !mygui->skin) return 0; | |
| 436 | |
| 33555 | 437 if(guiInfo.mpcontext) |
| 23077 | 438 { |
| 33555 | 439 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
| 440 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
| 441 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
| 442 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
| 23077 | 443 } |
| 444 | |
| 33726 | 445 switch (what) |
| 23077 | 446 { |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
447 case GUI_PREPARE: |
| 23077 | 448 { |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
449 gui(GUI_SET_FILE, 0); |
| 33555 | 450 guiInfo.NewPlay = 0; |
| 451 switch(guiInfo.StreamType) | |
| 23077 | 452 { |
| 453 case STREAMTYPE_PLAYLIST: | |
| 454 break; | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
455 #ifdef CONFIG_DVDREAD |
| 23077 | 456 case STREAMTYPE_DVD: |
| 457 { | |
| 458 char tmp[512]; | |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
459 dvd_title = guiInfo.Track; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
460 dvd_chapter = guiInfo.Chapter; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
461 dvd_angle = guiInfo.Angle; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
462 sprintf(tmp,"dvd://%d", guiInfo.Track); |
|
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
463 setdup(&guiInfo.Filename, tmp); |
| 23077 | 464 break; |
| 465 } | |
| 466 #endif | |
| 467 } | |
| 33555 | 468 if(guiInfo.Filename) |
| 469 filename = strdup(guiInfo.Filename); | |
| 23077 | 470 else if(filename) |
| 33555 | 471 strcpy(guiInfo.Filename, filename); |
| 23077 | 472 break; |
| 473 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
474 case GUI_SET_AUDIO: |
| 23077 | 475 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
476 guiInfo.MovieWindow = (data && !guiInfo.sh_video); |
| 33661 | 477 // NOTE: This type doesn't mean (and never meant) that we have |
| 478 // *just* audio, so there probably should be a check before | |
| 479 // hiding (see gui/interface.c). | |
| 23077 | 480 if(IsWindowVisible(mygui->subwindow)) |
| 481 ShowWindow(mygui->subwindow, SW_HIDE); | |
| 482 break; | |
| 483 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
484 case GUI_SET_CONTEXT: |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
485 guiInfo.mpcontext = data; |
| 23077 | 486 break; |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
487 case GUI_SET_VIDEO: |
| 23077 | 488 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
489 guiInfo.sh_video = data; |
|
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
490 if (data) |
| 23077 | 491 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
492 sh_video_t *sh = data; |
| 23077 | 493 codecname = sh->codec->name; |
| 494 | |
| 495 /* we have video, show the subwindow */ | |
| 496 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
| 497 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
| 498 if(WinID == -1) | |
| 499 update_subwindow(); | |
| 500 | |
| 501 } | |
| 502 break; | |
| 503 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
504 case GUI_SETUP_VIDEO_WINDOW: |
| 23077 | 505 { |
| 33555 | 506 guiInfo.MovieWidth = vo_dwidth; |
| 507 guiInfo.MovieHeight = vo_dheight; | |
| 23077 | 508 |
| 33555 | 509 sub_aspect = (float)guiInfo.MovieWidth/guiInfo.MovieHeight; |
| 23077 | 510 if(WinID != -1) |
| 511 update_subwindow(); | |
| 512 break; | |
| 513 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
514 case GUI_SET_STREAM: |
| 23077 | 515 { |
| 33555 | 516 guiInfo.StreamType = stream->type; |
| 23077 | 517 switch(stream->type) |
| 518 { | |
|
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
519 #ifdef CONFIG_DVDREAD |
| 23077 | 520 case STREAMTYPE_DVD: |
| 33730 | 521 dvdp = stream->priv; |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
522 guiInfo.Tracks = dvdp->vmg_file->tt_srpt->nr_of_srpts; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
523 guiInfo.Chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
524 guiInfo.Angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; |
| 33730 | 525 guiInfo.DVD.nr_of_audio_channels = dvdp->nr_of_channels; |
| 526 memcpy(guiInfo.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
| 527 guiInfo.DVD.nr_of_subtitles = dvdp->nr_of_subtitles; | |
| 528 memcpy(guiInfo.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
529 guiInfo.Chapter = dvd_chapter + 1; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
530 guiInfo.Angle = dvd_angle + 1; |
| 33730 | 531 guiInfo.Track = dvd_title + 1; |
| 23077 | 532 break; |
| 533 #endif | |
| 534 } | |
| 535 break; | |
| 536 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
537 case GUI_REDRAW: |
| 23077 | 538 mygui->updatedisplay(mygui, mygui->mainwindow); |
| 539 break; | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
540 case GUI_SET_AFILTER: |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
541 guiInfo.afilter = data; |
| 23077 | 542 break; |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
543 case GUI_SET_STATE: |
| 23077 | 544 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
545 guiInfo.Playing = (int) data; |
| 33555 | 546 switch (guiInfo.Playing) |
| 23077 | 547 { |
| 33614 | 548 case GUI_PLAY: |
| 23077 | 549 { |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
550 guiInfo.Playing = GUI_PLAY; |
| 23077 | 551 break; |
| 552 } | |
| 33614 | 553 case GUI_STOP: |
| 23077 | 554 { |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
555 guiInfo.Playing = GUI_STOP; |
| 23077 | 556 if(movie_aspect >= 0) |
| 557 movie_aspect = -1; | |
| 558 update_subwindow(); | |
| 559 break; | |
| 560 } | |
| 33614 | 561 case GUI_PAUSE: |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
562 guiInfo.Playing = GUI_PAUSE; |
| 23077 | 563 break; |
| 564 } | |
| 565 break; | |
| 566 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
567 case GUI_RUN_COMMAND: |
| 23077 | 568 { |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
569 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) data); |
| 23077 | 570 /* MPlayer asks us to quit */ |
|
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
571 switch((int) data) |
| 23077 | 572 { |
|
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
573 case MP_CMD_VO_FULLSCREEN: |
| 33555 | 574 uiFullScreen(); |
| 23077 | 575 break; |
| 576 case MP_CMD_QUIT: | |
| 577 { | |
| 578 mygui->uninit(mygui); | |
| 33770 | 579 nfree(mygui); |
| 30558 | 580 exit_player(EXIT_QUIT); |
|
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
581 return 1; |
| 23077 | 582 } |
|
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
583 case MP_CMD_PLAY_TREE_STEP: |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
584 guiSetEvent(evNext); |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
585 break; |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
586 case -MP_CMD_PLAY_TREE_STEP: |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
587 guiSetEvent(evPrev); |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
588 break; |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
589 case MP_CMD_STOP: |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
590 guiSetEvent(evStop); |
|
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
591 break; |
| 23077 | 592 default: |
| 593 break; | |
| 594 } | |
| 595 break; | |
| 596 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
597 case GUI_SET_FILE: |
| 23077 | 598 { |
| 599 audio_id = -1; | |
| 600 video_id = -1; | |
| 601 dvdsub_id = -1; | |
| 602 vobsub_id = -1; | |
| 603 stream_cache_size = -1; | |
| 604 autosync = 0; | |
| 605 dvd_title = 0; | |
| 606 force_fps = 0; | |
| 607 if(!mygui->playlist->tracks) return 0; | |
| 33555 | 608 filename = guiInfo.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename; |
| 609 guiInfo.Track = mygui->playlist->current + 1; | |
| 23077 | 610 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
| 611 if(gtkAOExtraStereo) | |
| 612 { | |
| 613 char *name = malloc(12 + 20 + 1); | |
| 614 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
| 615 name[12 + 20] = 0; | |
| 616 greplace(&af_cfg.list, "extrastereo", name); | |
| 617 free(name); | |
| 618 } | |
| 619 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
| 620 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
| 621 break; | |
| 622 } | |
| 33732 | 623 case GUI_HANDLE_EVENTS: |
| 624 break; | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
625 case GUI_SET_MIXER: |
| 23077 | 626 { |
| 627 if(audio_out) | |
| 628 { | |
| 629 /* Some audio_out drivers do not support balance e.g. dsound */ | |
| 630 /* FIXME this algo is not correct */ | |
| 631 float l, r; | |
| 632 mixer_getvolume(mixer, &l, &r); | |
| 33555 | 633 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
| 23077 | 634 if (r != l) |
| 33555 | 635 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
| 23077 | 636 else |
| 33555 | 637 guiInfo.Balance = 50.0f; |
| 23077 | 638 } |
| 639 break; | |
| 640 } | |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
641 case GUI_END_FILE: |
|
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
642 { |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
643 if(!uiGotoTheNext && guiInfo.Playing) |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
644 { |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
645 uiGotoTheNext = 1; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
646 break; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
647 } |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
648 |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
649 if(uiGotoTheNext && guiInfo.Playing && |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
650 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
651 guiInfo.StreamType != STREAMTYPE_DVD && |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
652 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
653 { |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
654 /* we've finished this file, reset the aspect */ |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
655 if(movie_aspect >= 0) |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
656 movie_aspect = -1; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
657 |
| 33894 | 658 uiGotoTheNext = 1; |
| 33890 | 659 guiInfo.NewPlay = GUI_FILE_NEW; |
|
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
660 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM); |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
661 //sprintf(guiInfo.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename); |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
662 } |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
663 |
| 33894 | 664 if(guiInfo.NewPlay == GUI_FILE_NEW) |
|
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
665 break; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
666 |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
667 guiInfo.TimeSec = 0; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
668 guiInfo.Position = 0; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
669 guiInfo.AudioChannels = 0; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
670 |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
671 #ifdef CONFIG_DVDREAD |
|
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
672 guiInfo.Track = 1; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
673 guiInfo.Chapter = 1; |
|
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
674 guiInfo.Angle = 1; |
|
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
675 #endif |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
676 |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
677 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
678 mygui->playlist->current = 0; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
679 |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
680 fullscreen = 0; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
681 if(style == WS_VISIBLE | WS_POPUP) |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
682 { |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
683 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
684 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
685 } |
|
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
686 gui(GUI_SET_STATE, (void *) GUI_STOP); |
|
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
687 break; |
|
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
688 } |
| 23077 | 689 default: |
| 33726 | 690 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
| 23077 | 691 } |
|
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
692 return 1; |
| 23077 | 693 } |
| 694 | |
| 695 /* This function adds/inserts one file into the gui playlist */ | |
| 33579 | 696 static int import_file_into_gui(char *pathname, int insert) |
| 23077 | 697 { |
| 698 char filename[MAX_PATH]; | |
| 699 char *filepart = filename; | |
| 700 | |
| 701 if (strstr(pathname, "://")) | |
| 702 { | |
| 703 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
| 704 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
| 705 return 1; | |
| 706 } | |
| 707 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
| 708 { | |
| 709 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
| 710 { | |
| 711 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
| 712 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
| 713 return 1; | |
| 714 } | |
| 715 else | |
| 716 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
| 717 } | |
| 718 | |
| 719 return 0; | |
| 720 } | |
| 721 | |
| 722 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
| 723 by either: | |
| 724 - overwriting gui pl (enqueue=0) */ | |
| 725 | |
| 33752 | 726 int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
| 23077 | 727 { |
| 728 play_tree_iter_t *my_pt_iter = NULL; | |
| 729 int result = 0; | |
| 730 | |
| 731 if(!mygui) guiInit(); | |
| 732 | |
| 733 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
| 734 { | |
| 735 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
| 736 { | |
| 737 if (parse_filename(filename, my_playtree, config, 0)) | |
| 738 result = 1; | |
| 739 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
| 740 result = 1; | |
| 741 } | |
| 742 } | |
| 33555 | 743 uiGotoTheNext = 1; |
| 23077 | 744 |
| 745 if (result) | |
| 746 { | |
| 747 mygui->playlist->current = 0; | |
| 748 filename = mygui->playlist->tracks[0]->filename; | |
| 749 } | |
| 750 return result; | |
| 751 } | |
| 752 | |
| 753 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
| 754 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
| 755 The file which contained the playlist is thereby replaced with it's contents. */ | |
| 756 | |
| 33752 | 757 int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config) |
| 23077 | 758 { |
| 759 play_tree_iter_t *my_pt_iter = NULL; | |
| 760 int result = 0; | |
| 761 | |
| 762 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
| 763 { | |
| 764 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
| 765 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
| 766 result = 1; | |
| 767 pt_iter_destroy(&my_pt_iter); | |
| 768 } | |
| 769 filename = NULL; | |
| 770 return result; | |
| 771 } | |
| 772 | |
| 33579 | 773 static inline void gtkMessageBox(int type, const char *str) |
| 23077 | 774 { |
| 775 if (type & GTK_MB_FATAL) | |
| 776 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR); | |
| 777 | |
| 778 fprintf(stderr, "[GUI] MessageBox: %s\n", str); | |
| 779 fflush(stderr); | |
| 780 } | |
| 781 | |
| 782 static int update_subwindow(void) | |
| 783 { | |
| 784 int x,y; | |
| 785 RECT rd; | |
| 786 WINDOWPOS wp; | |
| 787 | |
| 788 if(!sub_window) | |
| 789 { | |
| 33567 | 790 WinID = -1; |
| 23077 | 791 |
| 33555 | 792 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
| 23077 | 793 { |
| 794 ShowWindow(mygui->subwindow, SW_HIDE); | |
| 795 return 0; | |
| 796 } | |
| 33679 | 797 else if(!guiInfo.MovieWindow) |
| 23077 | 798 return 0; |
| 799 else ShowWindow(mygui->subwindow, SW_SHOW); | |
| 800 } | |
| 801 | |
| 802 /* we've come out of fullscreen at the end of file */ | |
| 33679 | 803 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.MovieWindow) |
| 23077 | 804 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
| 805 | |
| 806 /* get our current window coordinates */ | |
| 807 GetWindowRect(mygui->subwindow, &rd); | |
| 808 | |
| 809 x = rd.left; | |
| 810 y = rd.top; | |
| 811 | |
| 812 /* restore sub window position when coming out of fullscreen */ | |
| 813 if(x <= 0) x = old_rect.left; | |
| 814 if(y <= 0) y = old_rect.top; | |
| 815 | |
| 33555 | 816 if(!guiInfo.Playing) |
| 23077 | 817 { |
| 818 window *desc = NULL; | |
| 819 int i; | |
| 820 | |
| 821 for (i=0; i<mygui->skin->windowcount; i++) | |
| 822 if(mygui->skin->windows[i]->type == wiSub) | |
| 823 desc = mygui->skin->windows[i]; | |
| 824 | |
| 825 rd.right = rd.left+desc->base->bitmap[0]->width; | |
| 826 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
| 827 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
| 828 } | |
| 829 else | |
| 830 { | |
| 33555 | 831 rd.right = rd.left+guiInfo.MovieWidth; |
| 832 rd.bottom = rd.top+guiInfo.MovieHeight; | |
| 23077 | 833 |
| 834 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
| 835 sub_aspect = movie_aspect; | |
| 836 } | |
| 837 | |
| 838 | |
| 839 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
| 840 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
| 841 | |
| 842 wp.hwnd = mygui->subwindow; | |
| 843 wp.x = rd.left; | |
| 844 wp.y = rd.top; | |
| 845 wp.cx = rd.right-rd.left; | |
| 846 wp.cy = rd.bottom-rd.top; | |
| 847 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
| 848 | |
| 849 /* erase the bitmap image if there's video */ | |
|
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
850 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
| 23077 | 851 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
| 852 | |
| 853 /* reset the window aspect */ | |
| 854 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
| 855 return 0; | |
| 856 } |
