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