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