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