Mercurial > mplayer.hg
annotate gui/win32/interface.c @ 34391:6b558b00939a
Fix Win32 GUI DVD playback.
The "open disk" menu item for DVDs didn't work.
Reported by Stephen Sheldon, sfsheldo gmail com.
author | ib |
---|---|
date | Sat, 31 Dec 2011 13:20:29 +0000 |
parents | f05c75392897 |
children | e195ad9bdc59 |
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 |
34115 | 26 #if defined(__CYGWIN__) || defined(__WINE__) |
33358 | 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]; | |
34391 | 117 guiInfo.Track = 1; |
118 guiInfo.Chapter = 1; | |
119 guiInfo.Angle = 1; | |
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); | |
128 mygui->playlist->clear_playlist(mygui->playlist); | |
129 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0); | |
34391 | 130 uiPlay(); |
23077 | 131 break; |
132 } | |
133 #endif | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
134 #ifdef CONFIG_LIBCDIO |
23077 | 135 case evPlayCD: |
136 { | |
137 int i; | |
138 char track[10]; | |
139 char trackname[10]; | |
140 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN); | |
141 track_t i_tracks; | |
142 | |
143 if(p_cdio == NULL) printf("Couldn't find a driver.\n"); | |
144 i_tracks = cdio_get_num_tracks(p_cdio); | |
145 | |
146 mygui->playlist->clear_playlist(mygui->playlist); | |
147 for(i=0;i<i_tracks;i++) | |
148 { | |
149 sprintf(track, "cdda://%d", i+1); | |
150 sprintf(trackname, "Track %d", i+1); | |
151 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0); | |
152 } | |
153 cdio_destroy(p_cdio); | |
154 mygui->startplay(mygui); | |
155 break; | |
156 } | |
157 #endif | |
158 case evFullScreen: | |
159 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
160 break; | |
161 case evExit: | |
162 { | |
163 /* We are asking mplayer to exit, later it will ask us after uninit is made | |
164 this should be the only safe way to quit */ | |
165 mygui->activewidget = NULL; | |
166 mp_input_queue_cmd(mp_input_parse_cmd("quit")); | |
167 break; | |
168 } | |
169 case evStop: | |
33555 | 170 if(guiInfo.Playing) |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
171 gui(GUI_SET_STATE, (void *) GUI_STOP); |
23077 | 172 break; |
173 case evSetMoviePosition: | |
174 { | |
33555 | 175 rel_seek_secs = guiInfo.Position / 100.0f; |
23077 | 176 abs_seek_pos = 3; |
177 break; | |
178 } | |
179 case evForward10sec: | |
180 { | |
181 rel_seek_secs = 10.0f; | |
182 abs_seek_pos = 0; | |
183 break; | |
184 } | |
185 case evBackward10sec: | |
186 { | |
187 rel_seek_secs = -10.0f; | |
188 abs_seek_pos = 0; | |
189 break; | |
190 } | |
191 case evSetBalance: | |
192 case evSetVolume: | |
193 { | |
194 float l,r; | |
195 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
196 if (guiInfo.Playing == GUI_STOP) |
23077 | 197 break; |
198 | |
33555 | 199 if (guiInfo.Balance == 50.0f) |
200 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); | |
23077 | 201 |
33555 | 202 l = guiInfo.Volume * ((100.0f - guiInfo.Balance) / 50.0f); |
203 r = guiInfo.Volume * ((guiInfo.Balance) / 50.0f); | |
23077 | 204 |
33555 | 205 if (l > guiInfo.Volume) l=guiInfo.Volume; |
206 if (r > guiInfo.Volume) r=guiInfo.Volume; | |
23077 | 207 mixer_setvolume(mixer, l, r); |
208 /* Check for balance support on mixer - there is a better way ?? */ | |
209 if (r != l) | |
210 { | |
211 mixer_getvolume(mixer, &l, &r); | |
212 if (r == l) | |
213 { | |
214 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n"); | |
33555 | 215 mixer_setvolume(mixer, guiInfo.Volume, guiInfo.Volume); |
216 guiInfo.Balance = 50.0f; | |
23077 | 217 } |
218 } | |
219 break; | |
220 } | |
221 case evMute: | |
222 { | |
223 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
224 cmd->id=MP_CMD_MUTE; | |
225 cmd->name=strdup("mute"); | |
226 mp_input_queue_cmd(cmd); | |
227 break; | |
228 } | |
229 case evLoadPlay: | |
230 { | |
33555 | 231 switch(guiInfo.StreamType) |
23077 | 232 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
233 #ifdef CONFIG_DVDREAD |
23077 | 234 case STREAMTYPE_DVD: |
235 { | |
33890 | 236 guiInfo.NewPlay = GUI_FILE_SAME; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
237 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 238 break; |
239 } | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23123
diff
changeset
|
240 #endif |
23077 | 241 default: |
242 { | |
33890 | 243 guiInfo.NewPlay = GUI_FILE_NEW; |
23077 | 244 update_playlistwindow(); |
33555 | 245 uiGotoTheNext = guiInfo.Playing? 0 : 1; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
246 gui(GUI_SET_STATE, (void *) GUI_STOP); |
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
247 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 248 break; |
249 } | |
250 } | |
251 break; | |
252 } | |
253 case evNext: | |
33555 | 254 uiNext(); |
23077 | 255 break; |
256 case evPrev: | |
33555 | 257 uiPrev(); |
23077 | 258 break; |
259 } | |
260 } | |
261 | |
33555 | 262 void uiPlay( void ) |
23077 | 263 { |
33555 | 264 if((!guiInfo.Filename ) || (guiInfo.Filename[0] == 0)) |
23077 | 265 return; |
266 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
267 if(guiInfo.Playing > GUI_STOP) |
23077 | 268 { |
33555 | 269 uiPause(); |
23077 | 270 return; |
271 } | |
33890 | 272 guiInfo.NewPlay = GUI_FILE_NEW; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
273 gui(GUI_SET_STATE, (void *) GUI_PLAY); |
23077 | 274 } |
275 | |
33555 | 276 void uiPause( void ) |
23077 | 277 { |
33555 | 278 if(!guiInfo.Playing) return; |
23077 | 279 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
280 if(guiInfo.Playing == GUI_PLAY) |
23077 | 281 { |
282 mp_cmd_t * cmd = calloc(1, sizeof(*cmd)); | |
283 cmd->id=MP_CMD_PAUSE; | |
284 cmd->name=strdup("pause"); | |
285 mp_input_queue_cmd(cmd); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
286 } else guiInfo.Playing = GUI_PLAY; |
23077 | 287 } |
288 | |
33555 | 289 void uiNext(void) |
23077 | 290 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
291 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 292 switch(guiInfo.StreamType) |
23077 | 293 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
294 #ifdef CONFIG_DVDREAD |
23077 | 295 case STREAMTYPE_DVD: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
296 if(guiInfo.Chapter == (guiInfo.Chapters - 1)) |
23077 | 297 return; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
298 guiInfo.Chapter++; |
23077 | 299 break; |
300 #endif | |
301 default: | |
302 if(mygui->playlist->current == (mygui->playlist->trackcount - 1)) | |
303 return; | |
33555 | 304 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, |
34075 | 305 STREAMTYPE_FILE); |
23077 | 306 break; |
307 } | |
308 mygui->startplay(mygui); | |
309 } | |
310 | |
33555 | 311 void uiPrev(void) |
23077 | 312 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
313 if(guiInfo.Playing == GUI_PAUSE) return; |
33555 | 314 switch(guiInfo.StreamType) |
23077 | 315 { |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
316 #ifdef CONFIG_DVDREAD |
23077 | 317 case STREAMTYPE_DVD: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
318 if(guiInfo.Chapter == 1) |
23077 | 319 return; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
320 guiInfo.Chapter--; |
23077 | 321 break; |
322 #endif | |
323 default: | |
324 if(mygui->playlist->current == 0) | |
325 return; | |
33555 | 326 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename, |
34075 | 327 STREAMTYPE_FILE); |
23077 | 328 break; |
329 } | |
330 mygui->startplay(mygui); | |
331 } | |
332 | |
34115 | 333 #ifdef __WINE__ |
334 /** | |
34117 | 335 * @brief Convert a Windows style path to a file name into an Unix style one. |
34115 | 336 * |
34117 | 337 * @param filename pointer to the file path to be converted |
34115 | 338 * |
34117 | 339 * @return pointer to the converted file path |
34115 | 340 */ |
341 static char *unix_name (char *filename) | |
342 { | |
343 static char *unix_filename; | |
344 LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR); | |
345 int wchar_conv; | |
346 | |
347 if (*filename && (filename[1] == ':')) | |
348 { | |
349 wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name"); | |
350 wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0); | |
351 | |
352 if (wine_get_unix_file_name_ptr && wchar_conv) | |
353 { | |
354 WCHAR *ntpath; | |
355 char *unix_name; | |
356 | |
357 ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1)); | |
358 MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv); | |
359 unix_name = wine_get_unix_file_name_ptr(ntpath); | |
360 setdup(&unix_filename, unix_name); | |
361 filename = unix_filename; | |
362 HeapFree(GetProcessHeap(), 0, unix_name); | |
363 HeapFree(GetProcessHeap(), 0, ntpath); | |
364 } | |
365 } | |
366 | |
367 return filename; | |
368 } | |
369 #endif | |
370 | |
33555 | 371 void uiSetFileName(char *dir, char *name, int type) |
23077 | 372 { |
373 if(!name) return; | |
374 if(!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
375 setdup(&guiInfo.Filename, name); |
23077 | 376 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33737
diff
changeset
|
377 setddup(&guiInfo.Filename, dir, name); |
23077 | 378 |
34064 | 379 filename = guiInfo.Filename; |
34115 | 380 #ifdef __WINE__ |
34127
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
381 // When the GUI receives the files to be played in guiPlaylistInitialize() |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
382 // and guiPlaylistAdd(), it calls import_file_into_gui() where the call of |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
383 // Wine's GetFullPathName() converts each file name into the Windows style |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
384 // (C:\path\to\file), which needs to be reconverted for MPlayer, so that |
98f6d11e2ff3
Revise comment on filename conversion in the Wine port.
ib
parents:
34126
diff
changeset
|
385 // it will find the filename in the Linux filesystem. |
34123 | 386 filename = unix_name(filename); |
34115 | 387 #endif |
33555 | 388 guiInfo.StreamType = type; |
34064 | 389 |
33897 | 390 nfree(guiInfo.AudioFilename); |
391 nfree(guiInfo.SubtitleFilename); | |
23077 | 392 } |
393 | |
33555 | 394 void uiFullScreen( void ) |
23077 | 395 { |
33555 | 396 if(!guiInfo.sh_video) return; |
23077 | 397 |
398 if(sub_window) | |
399 { | |
400 if(!fullscreen && IsWindowVisible(mygui->subwindow) && !IsIconic(mygui->subwindow)) | |
401 GetWindowRect(mygui->subwindow, &old_rect); | |
402 | |
403 if(fullscreen) | |
404 { | |
405 fullscreen = 0; | |
406 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; | |
407 } else { | |
408 fullscreen = 1; | |
409 style = WS_VISIBLE | WS_POPUP; | |
410 } | |
411 SetWindowLong(mygui->subwindow, GWL_STYLE, style); | |
412 update_subwindow(); | |
413 } | |
414 video_out->control(VOCTRL_FULLSCREEN, 0); | |
415 if(sub_window) ShowWindow(mygui->subwindow, SW_SHOW); | |
416 } | |
417 | |
24992 | 418 static unsigned __stdcall GuiThread(void* param) |
23077 | 419 { |
420 MSG msg; | |
421 | |
422 if(!skinName) skinName = strdup("Blue"); | |
33781 | 423 if(!mygui) mygui = create_gui(get_path("skins"), guiSetEvent); |
30558 | 424 if(!mygui) exit_player(EXIT_ERROR); |
23077 | 425 |
426 if(autosync && autosync != gtkAutoSync) | |
427 { | |
428 gtkAutoSyncOn = 1; | |
429 gtkAutoSync = autosync; | |
430 } | |
431 | |
24992 | 432 while(GetMessage(&msg, NULL, 0, 0)) |
23077 | 433 { |
434 TranslateMessage(&msg); | |
435 DispatchMessage(&msg); | |
436 } | |
23078 | 437 fprintf(stderr, "[GUI] GUI thread terminated.\n"); |
23077 | 438 fflush(stderr); |
439 return 0; | |
440 } | |
441 | |
442 void guiInit(void) | |
443 { | |
33555 | 444 memset(&guiInfo, 0, sizeof(guiInfo)); |
23077 | 445 /* Create The gui thread */ |
446 if (!mygui) | |
447 { | |
33358 | 448 hThread = _beginthreadex(NULL, 0, GuiThread, NULL, 0, &threadId); |
23077 | 449 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n", threadId); |
450 } | |
451 | |
452 /* Wait until the gui is created */ | |
453 while(!mygui) Sleep(100); | |
23078 | 454 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] GUI thread started.\n"); |
23077 | 455 } |
456 | |
457 void guiDone(void) | |
458 { | |
459 if(mygui) | |
460 { | |
461 fprintf(stderr, "[GUI] Closed by main mplayer window\n"); | |
462 fflush(stderr); | |
24992 | 463 PostThreadMessage(threadId, WM_QUIT, 0, 0); |
464 WaitForSingleObject(hThread, INFINITE); | |
465 CloseHandle(hThread); | |
23077 | 466 mygui->uninit(mygui); |
33770 | 467 nfree(mygui); |
23077 | 468 } |
469 /* Remove tray icon */ | |
470 Shell_NotifyIcon(NIM_DELETE, &nid); | |
471 cfg_write(); | |
472 } | |
473 | |
474 /* 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
|
475 int gui(int what, void *data) |
23077 | 476 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
477 stream_t *stream = data; |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
478 #ifdef CONFIG_DVDREAD |
33730 | 479 dvd_priv_t *dvdp; |
23077 | 480 #endif |
481 if(!mygui || !mygui->skin) return 0; | |
482 | |
33555 | 483 if(guiInfo.mpcontext) |
23077 | 484 { |
33555 | 485 audio_out = mpctx_get_audio_out(guiInfo.mpcontext); |
486 video_out = mpctx_get_video_out(guiInfo.mpcontext); | |
487 mixer = mpctx_get_mixer(guiInfo.mpcontext); | |
488 playtree = mpctx_get_playtree_iter(guiInfo.mpcontext); | |
23077 | 489 } |
490 | |
33726 | 491 switch (what) |
23077 | 492 { |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
493 case GUI_PREPARE: |
23077 | 494 { |
34052 | 495 audio_id = -1; |
496 video_id = -1; | |
497 dvdsub_id = -1; | |
498 vobsub_id = -1; | |
499 stream_cache_size = -1; | |
500 autosync = 0; | |
501 dvd_title = 0; | |
502 force_fps = 0; | |
503 if(!mygui->playlist->tracks) return 0; | |
34391 | 504 switch(guiInfo.StreamType) |
505 { | |
506 case STREAMTYPE_FILE: | |
507 case STREAMTYPE_STREAM: | |
508 uiSetFileName(NULL, mygui->playlist->tracks[mygui->playlist->current]->filename, STREAMTYPE_FILE); | |
509 guiInfo.Track = mygui->playlist->current + 1; | |
510 break; | |
511 #ifdef CONFIG_DVDREAD | |
512 case STREAMTYPE_DVD: | |
513 { | |
514 char tmp[512]; | |
515 dvd_chapter = guiInfo.Chapter; | |
516 dvd_angle = guiInfo.Angle; | |
517 sprintf(tmp,"dvd://%d", guiInfo.Track); | |
518 uiSetFileName(NULL, tmp, STREAMTYPE_DVD); | |
519 break; | |
520 } | |
521 #endif | |
522 } | |
34126 | 523 guiInfo.VideoWindow = 1; |
34052 | 524 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm"); |
525 if(gtkAOExtraStereo) | |
526 { | |
527 char *name = malloc(12 + 20 + 1); | |
528 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul); | |
529 name[12 + 20] = 0; | |
530 greplace(&af_cfg.list, "extrastereo", name); | |
531 free(name); | |
532 } | |
533 if(gtkCacheOn) stream_cache_size = gtkCacheSize; | |
534 if(gtkAutoSyncOn) autosync = gtkAutoSync; | |
33555 | 535 guiInfo.NewPlay = 0; |
23077 | 536 break; |
537 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
538 case GUI_SET_AUDIO: |
23077 | 539 { |
34126 | 540 if (data && !guiInfo.sh_video) guiInfo.VideoWindow = 0; |
541 if(IsWindowVisible(mygui->subwindow) && !guiInfo.VideoWindow) | |
23077 | 542 ShowWindow(mygui->subwindow, SW_HIDE); |
543 break; | |
544 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
545 case GUI_SET_CONTEXT: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
546 guiInfo.mpcontext = data; |
23077 | 547 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
548 case GUI_SET_VIDEO: |
23077 | 549 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
550 guiInfo.sh_video = data; |
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
551 if (data) |
23077 | 552 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
553 sh_video_t *sh = data; |
23077 | 554 codecname = sh->codec->name; |
555 | |
556 /* we have video, show the subwindow */ | |
557 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) | |
558 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); | |
559 if(WinID == -1) | |
560 update_subwindow(); | |
561 | |
562 } | |
563 break; | |
564 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
565 case GUI_SETUP_VIDEO_WINDOW: |
23077 | 566 { |
33901 | 567 guiInfo.VideoWidth = vo_dwidth; |
568 guiInfo.VideoHeight = vo_dheight; | |
23077 | 569 |
33901 | 570 sub_aspect = (float)guiInfo.VideoWidth/guiInfo.VideoHeight; |
23077 | 571 if(WinID != -1) |
572 update_subwindow(); | |
573 break; | |
574 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
575 case GUI_SET_STREAM: |
23077 | 576 { |
33555 | 577 guiInfo.StreamType = stream->type; |
23077 | 578 switch(stream->type) |
579 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26457
diff
changeset
|
580 #ifdef CONFIG_DVDREAD |
23077 | 581 case STREAMTYPE_DVD: |
33730 | 582 dvdp = stream->priv; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
583 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
|
584 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
|
585 guiInfo.Angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; |
33902 | 586 guiInfo.AudioStreams = dvdp->nr_of_channels; |
587 memcpy(guiInfo.AudioStream, dvdp->audio_streams, sizeof(dvdp->audio_streams)); | |
588 guiInfo.Subtitles = dvdp->nr_of_subtitles; | |
589 memcpy(guiInfo.Subtitle, dvdp->subtitles, sizeof(dvdp->subtitles)); | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
590 guiInfo.Chapter = dvd_chapter + 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
591 guiInfo.Angle = dvd_angle + 1; |
33730 | 592 guiInfo.Track = dvd_title + 1; |
23077 | 593 break; |
594 #endif | |
595 } | |
596 break; | |
597 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
598 case GUI_REDRAW: |
23077 | 599 mygui->updatedisplay(mygui, mygui->mainwindow); |
600 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
601 case GUI_SET_AFILTER: |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
602 guiInfo.afilter = data; |
23077 | 603 break; |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
604 case GUI_SET_STATE: |
23077 | 605 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
606 guiInfo.Playing = (int) data; |
33555 | 607 switch (guiInfo.Playing) |
23077 | 608 { |
33614 | 609 case GUI_PLAY: |
23077 | 610 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
611 guiInfo.Playing = GUI_PLAY; |
23077 | 612 break; |
613 } | |
33614 | 614 case GUI_STOP: |
23077 | 615 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
616 guiInfo.Playing = GUI_STOP; |
23077 | 617 if(movie_aspect >= 0) |
618 movie_aspect = -1; | |
619 update_subwindow(); | |
620 break; | |
621 } | |
33614 | 622 case GUI_PAUSE: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
623 guiInfo.Playing = GUI_PAUSE; |
23077 | 624 break; |
625 } | |
626 break; | |
627 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
628 case GUI_RUN_COMMAND: |
23077 | 629 { |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
630 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) data); |
23077 | 631 /* MPlayer asks us to quit */ |
33791
8b0c78a85a8c
Cosmetic: Change parameter names of gui() and mplayer().
ib
parents:
33781
diff
changeset
|
632 switch((int) data) |
23077 | 633 { |
31312
0b7792622c88
Remove Gui-specific slave commands and associated key-bindings and other code.
reimar
parents:
30901
diff
changeset
|
634 case MP_CMD_VO_FULLSCREEN: |
33555 | 635 uiFullScreen(); |
23077 | 636 break; |
637 case MP_CMD_QUIT: | |
638 { | |
639 mygui->uninit(mygui); | |
33770 | 640 nfree(mygui); |
30558 | 641 exit_player(EXIT_QUIT); |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
642 return 1; |
23077 | 643 } |
33696
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
644 case MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
645 guiSetEvent(evNext); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
646 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
647 case -MP_CMD_PLAY_TREE_STEP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
648 guiSetEvent(evPrev); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
649 break; |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
650 case MP_CMD_STOP: |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
651 guiSetEvent(evStop); |
24d919fb6778
Don't let MPlayer directly call user interface functions.
ib
parents:
33695
diff
changeset
|
652 break; |
23077 | 653 default: |
654 break; | |
655 } | |
656 break; | |
657 } | |
34339 | 658 case GUI_RUN_MESSAGE: |
659 break; | |
33732 | 660 case GUI_HANDLE_EVENTS: |
661 break; | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
662 case GUI_SET_MIXER: |
23077 | 663 { |
664 if(audio_out) | |
665 { | |
666 /* Some audio_out drivers do not support balance e.g. dsound */ | |
667 /* FIXME this algo is not correct */ | |
668 float l, r; | |
669 mixer_getvolume(mixer, &l, &r); | |
33555 | 670 guiInfo.Volume = (r > l ? r : l); /* max(r,l) */ |
23077 | 671 if (r != l) |
33555 | 672 guiInfo.Balance = ((r-l) + 100.0f) * 0.5f; |
23077 | 673 else |
33555 | 674 guiInfo.Balance = 50.0f; |
23077 | 675 } |
676 break; | |
677 } | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
678 case GUI_END_FILE: |
33694
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 if(!uiGotoTheNext && guiInfo.Playing) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
681 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
682 uiGotoTheNext = 1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
683 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
684 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
685 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
686 if(uiGotoTheNext && guiInfo.Playing && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
687 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
688 guiInfo.StreamType != STREAMTYPE_DVD && |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
689 guiInfo.StreamType != STREAMTYPE_DVDNAV) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
690 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
691 /* we've finished this file, reset the aspect */ |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
692 if(movie_aspect >= 0) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
693 movie_aspect = -1; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
694 |
33894 | 695 uiGotoTheNext = 1; |
33890 | 696 guiInfo.NewPlay = GUI_FILE_NEW; |
34075 | 697 uiSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_FILE); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
698 //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
|
699 } |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
700 |
33894 | 701 if(guiInfo.NewPlay == GUI_FILE_NEW) |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
702 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
703 |
33897 | 704 guiInfo.ElapsedTime = 0; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
705 guiInfo.Position = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
706 guiInfo.AudioChannels = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
707 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
708 #ifdef CONFIG_DVDREAD |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
709 guiInfo.Track = 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
710 guiInfo.Chapter = 1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33791
diff
changeset
|
711 guiInfo.Angle = 1; |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
712 #endif |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
713 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
714 if (mygui->playlist->current == (mygui->playlist->trackcount - 1)) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
715 mygui->playlist->current = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
716 |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
717 fullscreen = 0; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
718 if(style == WS_VISIBLE | WS_POPUP) |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
719 { |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
720 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
721 SetWindowLong(mygui->subwindow, GWL_STYLE, style); |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
722 } |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33730
diff
changeset
|
723 gui(GUI_SET_STATE, (void *) GUI_STOP); |
33694
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
724 break; |
45553d0f65c6
Don't let MPlayer directly call user interface functions.
ib
parents:
33691
diff
changeset
|
725 } |
23077 | 726 default: |
33726 | 727 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", what); |
23077 | 728 } |
33666
0f592e8530f1
Change return code of guiGetEvent() to indicate success.
ib
parents:
33661
diff
changeset
|
729 return 1; |
23077 | 730 } |
731 | |
732 /* This function adds/inserts one file into the gui playlist */ | |
33579 | 733 static int import_file_into_gui(char *pathname, int insert) |
23077 | 734 { |
735 char filename[MAX_PATH]; | |
736 char *filepart = filename; | |
737 | |
738 if (strstr(pathname, "://")) | |
739 { | |
740 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname); | |
741 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0); | |
742 return 1; | |
743 } | |
744 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart)) | |
745 { | |
746 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)) | |
747 { | |
748 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename); | |
749 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0); | |
750 return 1; | |
751 } | |
752 else | |
753 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename); | |
754 } | |
755 | |
756 return 0; | |
757 } | |
758 | |
759 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist | |
760 by either: | |
761 - overwriting gui pl (enqueue=0) */ | |
762 | |
33752 | 763 int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue) |
23077 | 764 { |
765 play_tree_iter_t *my_pt_iter = NULL; | |
766 int result = 0; | |
767 | |
768 if(!mygui) guiInit(); | |
769 | |
770 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
771 { | |
772 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
773 { | |
774 if (parse_filename(filename, my_playtree, config, 0)) | |
775 result = 1; | |
776 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */ | |
777 result = 1; | |
778 } | |
779 } | |
33555 | 780 uiGotoTheNext = 1; |
23077 | 781 |
782 if (result) | |
783 { | |
784 mygui->playlist->current = 0; | |
34068 | 785 uiSetFileName(NULL, mygui->playlist->tracks[0]->filename, STREAMTYPE_FILE); |
23077 | 786 } |
34084 | 787 |
788 if (enqueue) filename = NULL; | |
789 | |
23077 | 790 return result; |
791 } | |
792 | |
793 /* This function imports and inserts an playtree, that is created "on the fly", for example by | |
794 parsing some MOV-Reference-File; or by loading an playlist with "File Open" | |
795 The file which contained the playlist is thereby replaced with it's contents. */ | |
796 | |
33752 | 797 int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config) |
23077 | 798 { |
799 play_tree_iter_t *my_pt_iter = NULL; | |
800 int result = 0; | |
801 | |
802 if((my_pt_iter = pt_iter_create(&my_playtree, config))) | |
803 { | |
804 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL) | |
805 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */ | |
806 result = 1; | |
807 pt_iter_destroy(&my_pt_iter); | |
808 } | |
809 return result; | |
810 } | |
811 | |
812 static int update_subwindow(void) | |
813 { | |
814 int x,y; | |
815 RECT rd; | |
816 WINDOWPOS wp; | |
817 | |
818 if(!sub_window) | |
819 { | |
33567 | 820 WinID = -1; |
23077 | 821 |
33555 | 822 if(IsWindowVisible(mygui->subwindow) && guiInfo.sh_video && guiInfo.Playing) |
23077 | 823 { |
824 ShowWindow(mygui->subwindow, SW_HIDE); | |
825 return 0; | |
826 } | |
33901 | 827 else if(!guiInfo.VideoWindow) |
23077 | 828 return 0; |
829 else ShowWindow(mygui->subwindow, SW_SHOW); | |
830 } | |
831 | |
832 /* we've come out of fullscreen at the end of file */ | |
33901 | 833 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && guiInfo.VideoWindow) |
23077 | 834 ShowWindow(mygui->subwindow, SW_SHOWNORMAL); |
835 | |
836 /* get our current window coordinates */ | |
837 GetWindowRect(mygui->subwindow, &rd); | |
838 | |
839 x = rd.left; | |
840 y = rd.top; | |
841 | |
842 /* restore sub window position when coming out of fullscreen */ | |
843 if(x <= 0) x = old_rect.left; | |
844 if(y <= 0) y = old_rect.top; | |
845 | |
33555 | 846 if(!guiInfo.Playing) |
23077 | 847 { |
848 window *desc = NULL; | |
849 int i; | |
850 | |
851 for (i=0; i<mygui->skin->windowcount; i++) | |
852 if(mygui->skin->windows[i]->type == wiSub) | |
853 desc = mygui->skin->windows[i]; | |
854 | |
855 rd.right = rd.left+desc->base->bitmap[0]->width; | |
856 rd.bottom = rd.top+desc->base->bitmap[0]->height; | |
857 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top); | |
858 } | |
859 else | |
860 { | |
33901 | 861 rd.right = rd.left+guiInfo.VideoWidth; |
862 rd.bottom = rd.top+guiInfo.VideoHeight; | |
23077 | 863 |
864 if (movie_aspect > 0.0) // forced aspect from the cmdline | |
865 sub_aspect = movie_aspect; | |
866 } | |
867 | |
868 | |
869 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
870 SetWindowPos(mygui->subwindow, 0, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
871 | |
872 wp.hwnd = mygui->subwindow; | |
873 wp.x = rd.left; | |
874 wp.y = rd.top; | |
875 wp.cx = rd.right-rd.left; | |
876 wp.cy = rd.bottom-rd.top; | |
877 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW; | |
878 | |
879 /* erase the bitmap image if there's video */ | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
880 if(guiInfo.Playing != GUI_STOP && guiInfo.sh_video) |
23077 | 881 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0); |
882 | |
883 /* reset the window aspect */ | |
884 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp); | |
885 return 0; | |
886 } |