annotate Gui/win32/interface.c @ 19031:45d4d4a4fead

center sub window option within the preferences dialog.
author vayne
date Wed, 12 Jul 2006 16:43:03 +0000
parents b83cefcd7e41
children 86350b4b8203
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1 /*
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
2 MPlayer Gui for win32
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
6
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
10 (at your option) any later version.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
11
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
15 GNU General Public License for more details.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
16
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
18 along with this program; if not, write to the Free Software
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
20 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
21
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
22 #include <windows.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
23 #include <interface.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
24 #include <m_option.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
25 #include <mixer.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
26 #include <mp_msg.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
27 #include <help_mp.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
28 #include <codec-cfg.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
29 #include <libmpdemux/stream.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
30 #include <libmpdemux/demuxer.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
31 #include <libmpdemux/stheader.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
32 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
33 #include <libmpdemux/stream_dvd.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
34 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
35 #include <input/input.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
36 #include <libvo/video_out.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
37 #include <libao2/audio_out.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
38 #include "gui.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
39 #include "dialogs.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
40 #include "wincfg.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
41 #ifdef HAVE_LIBCDIO
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
42 #include <cdio/cdio.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
43 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
44
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
45 extern m_obj_settings_t* vo_plugin_args;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
46 extern vo_functions_t *video_out;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
47 extern ao_functions_t *audio_out;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
48 extern void exit_player(char *how);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
49 extern char *filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
50 extern int abs_seek_pos;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
51 extern float rel_seek_secs;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
52 extern mixer_t mixer;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
53 extern int audio_id;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
54 extern int video_id;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
55 extern int dvdsub_id;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
56 extern int vobsub_id;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
57 extern int stream_cache_size;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
58 extern int autosync;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
59 extern int vcd_track;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
60 extern int dvd_title;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
61 extern float force_fps;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
62 extern af_cfg_t af_cfg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
63 int guiWinID = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
64
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
65 char *skinName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
66 char *codecname = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
67 int mplGotoTheNext = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
68 static gui_t *mygui = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
69 static int update_subwindow(void);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
70
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
71 /* test for playlist files, no need to specify -playlist on the commandline.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
72 * add any conceivable playlist extensions here.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
73 * - Erik
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
74 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
75 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
76 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
77 if(clear)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
78 mygui->playlist->clear_playlist(mygui->playlist);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
79
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
80 if(strstr(file, ".m3u") || strstr(file, ".pls"))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
81 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
82 playtree = parse_playlist_file(file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
83 import_playtree_playlist_into_gui(playtree, mconfig);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
84 return 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
85 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
86 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
87 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
88
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
89 /**
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
90 * \brief this actually creates a new list containing only one element...
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
91 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
92 void gaddlist( char ***list, char *entry)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
93 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
94 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
95
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
96 if (*list)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
97 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
98 for (i=0; (*list)[i]; i++) free((*list)[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
99 free(*list);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
100 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
101
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
102 *list = malloc(2 * sizeof(char **));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
103 (*list)[0] = gstrdup(entry);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
104 (*list)[1] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
105 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
106
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
107 char *gstrdup(char *str)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
108 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
109 if (!str) return NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
110 return strdup(str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
111 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
112
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
113 /**
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
114 * \brief this replaces a string starting with search by replace.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
115 * If not found, replace is appended.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
116 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
117 void greplace(char ***list, char *search, char *replace)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
118 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
119 int i = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
120 int len = (search) ? strlen(search) : 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
121
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
122 if (*list)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
123 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
124 for (i = 0; (*list)[i]; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
125 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
126 if (search && (!strncmp((*list)[i], search, len)))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
127 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
128 free((*list)[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
129 (*list)[i] = gstrdup(replace);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
130 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
131 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
132 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
133 *list = realloc(*list, (i + 2) * sizeof(char *));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
134 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
135 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
136 *list = malloc(2 * sizeof(char *));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
137
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
138 (*list)[i] = gstrdup(replace);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
139 (*list)[i + 1] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
140 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
141
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
142 /* this function gets called by the gui to update mplayer */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
143 static void guiSetEvent(int event)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
144 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
145 switch(event)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
146 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
147 case evPlay:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
148 case evPlaySwitchToPause:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
149 mplPlay();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
150 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
151 case evPause:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
152 mplPause();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
153 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
154 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
155 case evPlayDVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
156 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
157 static char dvdname[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
158 guiIntfStruct.DVD.current_title = dvd_title;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
159 guiIntfStruct.DVD.current_chapter = dvd_chapter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
160 guiIntfStruct.DVD.current_angle = dvd_angle;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
161 guiIntfStruct.DiskChanged = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
162
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
163 mplSetFileName(NULL, dvd_device, STREAMTYPE_DVD);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
164 guiIntfStruct.Title = guiIntfStruct.DVD.current_title;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
165 guiIntfStruct.Chapter = guiIntfStruct.DVD.current_chapter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
166 guiIntfStruct.Angle = guiIntfStruct.DVD.current_angle;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
167
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
168 dvdname[0] = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
169 strcat(dvdname, "DVD Movie");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
170 GetVolumeInformation(dvd_device, dvdname, MAX_PATH, NULL, NULL, NULL, NULL, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
171 capitalize(dvdname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
172 mp_msg(MSGT_GPLAYER, MSGL_V, "Opening DVD %s -> %s\n", dvd_device, dvdname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
173 guiGetEvent(guiSetParameters, (char *) STREAMTYPE_DVD);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
174 mygui->playlist->clear_playlist(mygui->playlist);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
175 mygui->playlist->add_track(mygui->playlist, filename, NULL, dvdname, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
176 mygui->startplay(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
177 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
178 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
179 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
180 #ifdef HAVE_LIBCDIO
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
181 case evPlayCD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
182 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
183 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
184 char track[10];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
185 char trackname[10];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
186 CdIo_t *p_cdio = cdio_open(NULL, DRIVER_UNKNOWN);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
187 track_t i_tracks;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
188
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
189 if(p_cdio == NULL) printf("Couldn't find a driver.\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
190 i_tracks = cdio_get_num_tracks(p_cdio);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
191
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
192 mygui->playlist->clear_playlist(mygui->playlist);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
193 for(i=0;i<i_tracks;i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
194 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
195 sprintf(track, "cdda://%d", i+1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
196 sprintf(trackname, "Track %d", i+1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
197 mygui->playlist->add_track(mygui->playlist, track, NULL, trackname, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
198 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
199 cdio_destroy(p_cdio);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
200 mygui->startplay(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
201 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
202 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
203 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
204 case evFullScreen:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
205 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen"));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
206 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
207 case evExit:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
208 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
209 /* We are asking mplayer to exit, later it will ask us after uninit is made
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
210 this should be the only safe way to quit */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
211 mygui->activewidget = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
212 mp_input_queue_cmd(mp_input_parse_cmd("quit"));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
213 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
214 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
215 case evStop:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
216 if(guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
217 guiGetEvent(guiCEvent, (void *) guiSetStop);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
218 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
219 case evSetMoviePosition:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
220 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
221 rel_seek_secs = guiIntfStruct.Position / 100.0f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
222 abs_seek_pos = 3;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
223 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
224 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
225 case evForward10sec:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
226 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
227 rel_seek_secs = 10.0f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
228 abs_seek_pos = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
229 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
230 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
231 case evBackward10sec:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
232 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
233 rel_seek_secs = -10.0f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
234 abs_seek_pos = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
235 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
236 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
237 case evSetBalance:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
238 case evSetVolume:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
239 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
240 float l,r;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
241
18953
b83cefcd7e41 crash fix when clicking on volume sliders when in stop state.
vayne
parents: 18947
diff changeset
242 if (guiIntfStruct.Playing == 0)
b83cefcd7e41 crash fix when clicking on volume sliders when in stop state.
vayne
parents: 18947
diff changeset
243 break;
b83cefcd7e41 crash fix when clicking on volume sliders when in stop state.
vayne
parents: 18947
diff changeset
244
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
245 if (guiIntfStruct.Balance == 50.0f)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
246 mixer_setvolume(&mixer, guiIntfStruct.Volume, guiIntfStruct.Volume);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
247
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
248 l = guiIntfStruct.Volume * ((100.0f - guiIntfStruct.Balance) / 50.0f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
249 r = guiIntfStruct.Volume * ((guiIntfStruct.Balance) / 50.0f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
250
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
251 if (l > guiIntfStruct.Volume) l=guiIntfStruct.Volume;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
252 if (r > guiIntfStruct.Volume) r=guiIntfStruct.Volume;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
253 mixer_setvolume(&mixer, l, r);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
254 /* Check for balance support on mixer - there is a better way ?? */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
255 if (r != l)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
256 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
257 mixer_getvolume(&mixer, &l, &r);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
258 if (r == l)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
259 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
260 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Mixer doesn't support balanced audio\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
261 mixer_setvolume(&mixer, guiIntfStruct.Volume, guiIntfStruct.Volume);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
262 guiIntfStruct.Balance = 50.0f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
263 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
264 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
265 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
266 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
267 case evMute:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
268 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
269 mp_cmd_t * cmd = (mp_cmd_t *)calloc(1, sizeof(*cmd));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
270 cmd->id=MP_CMD_MUTE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
271 cmd->name=strdup("mute");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
272 mp_input_queue_cmd(cmd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
273 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
274 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
275 case evDropFile:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
276 case evLoadPlay:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
277 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
278 mplSetFileName(NULL, filename, STREAMTYPE_FILE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
279 guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
280 update_playlistwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
281 guiGetEvent(guiCEvent, (void *) guiSetStop);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
282 guiGetEvent(guiCEvent, (void *) guiSetPlay);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
283 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
284 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
285 case evNext:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
286 mplNext();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
287 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
288 case evPrev:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
289 mplPrev();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
290 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
291 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
292 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
293
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
294 void mplPlay( void )
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
295 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
296 if((!guiIntfStruct.Filename ) || (guiIntfStruct.Filename[0] == 0))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
297 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
298
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
299 if(guiIntfStruct.Playing > 0)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
300 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
301 mplPause();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
302 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
303 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
304 guiIntfStruct.NewPlay = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
305 guiGetEvent(guiCEvent, (void *) guiSetPlay);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
306 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
307
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
308 void mplPause( void )
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
309 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
310 if(!guiIntfStruct.Playing) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
311
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
312 if(guiIntfStruct.Playing == 1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
313 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
314 mp_cmd_t * cmd = (mp_cmd_t *)calloc(1, sizeof(*cmd));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
315 cmd->id=MP_CMD_PAUSE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
316 cmd->name=strdup("pause");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
317 mp_input_queue_cmd(cmd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
318 } else guiIntfStruct.Playing = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
319 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
320
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
321 void mplNext(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
322 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
323 if(guiIntfStruct.Playing == 2) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
324 switch(guiIntfStruct.StreamType)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
325 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
326 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
327 case STREAMTYPE_DVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
328 if(guiIntfStruct.DVD.current_chapter == (guiIntfStruct.DVD.chapters - 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
329 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
330 guiIntfStruct.DVD.current_chapter++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
331 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
332 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
333 default:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
334 if(mygui->playlist->current == (mygui->playlist->trackcount - 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
335 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
336 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
337 STREAMTYPE_STREAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
338 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
339 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
340 mplGotoTheNext = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
341 mygui->startplay(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
342 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
343
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
344 void mplPrev(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
345 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
346 if(guiIntfStruct.Playing == 2) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
347 switch(guiIntfStruct.StreamType)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
348 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
349 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
350 case STREAMTYPE_DVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
351 if(guiIntfStruct.DVD.current_chapter == 1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
352 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
353 guiIntfStruct.DVD.current_chapter--;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
354 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
355 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
356 default:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
357 if(mygui->playlist->current == 0)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
358 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
359 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)--]->filename,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
360 STREAMTYPE_STREAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
361 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
362 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
363 mplGotoTheNext = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
364 mygui->startplay(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
365 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
366
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
367 void mplEnd( void )
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
368 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
369 if(!mplGotoTheNext && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
370 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
371 mplGotoTheNext = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
372 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
373 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
374
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
375 if(mplGotoTheNext && guiIntfStruct.Playing &&
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
376 (mygui->playlist->current < (mygui->playlist->trackcount - 1)) &&
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
377 guiIntfStruct.StreamType != STREAMTYPE_DVD &&
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
378 guiIntfStruct.StreamType != STREAMTYPE_DVDNAV)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
379 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
380 /* we've finished this file, reset the aspect */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
381 if(movie_aspect >= 0)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
382 movie_aspect = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
383
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
384 mplGotoTheNext = guiIntfStruct.FilenameChanged = guiIntfStruct.NewPlay = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
385 mplSetFileName(NULL, mygui->playlist->tracks[(mygui->playlist->current)++]->filename, STREAMTYPE_STREAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
386 //sprintf(guiIntfStruct.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
387 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
388
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
389 if(guiIntfStruct.FilenameChanged && guiIntfStruct.NewPlay)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
390 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
391
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
392 guiIntfStruct.TimeSec = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
393 guiIntfStruct.Position = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
394 guiIntfStruct.AudioType = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
395
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
396 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
397 guiIntfStruct.DVD.current_title = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
398 guiIntfStruct.DVD.current_chapter = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
399 guiIntfStruct.DVD.current_angle = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
400 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
401
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
402 if (mygui->playlist->current == (mygui->playlist->trackcount - 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
403 mygui->playlist->current = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
404
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
405 guiGetEvent(guiCEvent, (void *) guiSetStop);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
406 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
407
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
408 void mplSetFileName(char *dir, char *name, int type)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
409 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
410 if(!name) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
411 if(!dir)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
412 guiSetFilename(guiIntfStruct.Filename, name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
413 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
414 guiSetDF(guiIntfStruct.Filename, dir, name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
415
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
416 guiIntfStruct.StreamType = type;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
417 free((void **) &guiIntfStruct.AudioFile);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
418 free((void **) &guiIntfStruct.Subtitlename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
419 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
420
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
421 static DWORD WINAPI GuiThread(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
422 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
423 MSG msg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
424
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
425 if(!skinName) skinName = strdup("Blue");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
426 if(!mygui) mygui = create_gui(get_path("skins"), skinName, guiSetEvent);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
427 if(!mygui) exit_player("Unable to load gui");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
428
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
429 if(autosync && autosync != gtkAutoSync)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
430 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
431 gtkAutoSyncOn = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
432 gtkAutoSync = autosync;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
433 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
434
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
435 while(mygui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
436 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
437 GetMessage(&msg, NULL, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
438 TranslateMessage(&msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
439 DispatchMessage(&msg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
440 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
441 fprintf(stderr, "[GUI] Gui Thread Terminated\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
442 fflush(stderr);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
443 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
444 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
445
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
446 void guiInit(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
447 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
448 memset(&guiIntfStruct, 0, sizeof(guiIntfStruct));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
449 /* Create The gui thread */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
450 if (!mygui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
451 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Creating GUI Thread 0x%04x\n",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
452 (int) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) GuiThread, NULL, 0, NULL));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
453
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
454 /* Wait until the gui is created */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
455 while(!mygui) Sleep(100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
456 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Gui Thread started\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
457 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
458
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
459 void guiDone(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
460 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
461 if(mygui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
462 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
463 fprintf(stderr, "[GUI] Closed by main mplayer window\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
464 fflush(stderr);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
465 mygui->uninit(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
466 free(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
467 TerminateThread(GuiThread, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
468 mygui = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
469 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
470 /* Remove tray icon */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
471 Shell_NotifyIcon(NIM_DELETE, &nid);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
472 cfg_write();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
473 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
474
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
475 static void add_vop(char * str)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
476 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
477 mp_msg(MSGT_GPLAYER, MSGL_STATUS, MSGTR_AddingVideoFilter, str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
478 if (vo_plugin_args)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
479 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
480 int i = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
481 while (vo_plugin_args[i].name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
482 if (!strcmp(vo_plugin_args[i++].name, str))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
483 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
484 i = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
485 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
486 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
487 if (i != -1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
488 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
489 vo_plugin_args = realloc(vo_plugin_args, (i + 2) * sizeof(m_obj_settings_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
490 vo_plugin_args[i].name = strdup(str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
491 vo_plugin_args[i].attribs = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
492 vo_plugin_args[i + 1].name = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
493 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
494 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
495 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
496 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
497 vo_plugin_args = malloc(2 * sizeof(m_obj_settings_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
498 vo_plugin_args[0].name = strdup(str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
499 vo_plugin_args[0].attribs = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
500 vo_plugin_args[1].name = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
501 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
502 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
503
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
504 static void remove_vop(char * str)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
505 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
506 int n = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
507 if (!vo_plugin_args ) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
508
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
509 mp_msg(MSGT_GPLAYER,MSGL_STATUS, MSGTR_RemovingVideoFilter, str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
510
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
511 while (vo_plugin_args[n++].name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
512 n--;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
513 if ( n > -1 )
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
514 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
515 int i = 0, m = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
516 while (vo_plugin_args[i].name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
517 if (!strcmp(vo_plugin_args[i++].name, str))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
518 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
519 m = i - 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
520 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
521 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
522 i--;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
523 if (m > -1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
524 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
525 if (n == 1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
526 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
527 free(vo_plugin_args[0].name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
528 free(vo_plugin_args[0].attribs);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
529 free(vo_plugin_args);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
530 vo_plugin_args=NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
531 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
532 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
533 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
534 free(vo_plugin_args[i].name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
535 free(vo_plugin_args[i].attribs);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
536 memcpy(&vo_plugin_args[i], &vo_plugin_args[i + 1], (n - i) * sizeof(m_obj_settings_t));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
537 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
538 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
539 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
540 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
541
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
542 /* this function gets called by mplayer to update the gui */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
543 int guiGetEvent(int type, char *arg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
544 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
545 if(!mygui || !mygui->skin) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
546
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
547 stream_t *stream = (stream_t *) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
548 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
549 dvd_priv_t *dvdp = (dvd_priv_t *) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
550 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
551
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
552 switch (type)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
553 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
554 case guiSetFileFormat:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
555 guiIntfStruct.FileFormat = (int) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
556 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
557 case guiSetParameters:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
558 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
559 guiGetEvent(guiSetDefaults, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
560 guiIntfStruct.DiskChanged = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
561 guiIntfStruct.FilenameChanged = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
562 guiIntfStruct.NewPlay = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
563 switch(guiIntfStruct.StreamType)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
564 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
565 case STREAMTYPE_PLAYLIST:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
566 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
567 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
568 case STREAMTYPE_DVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
569 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
570 char tmp[512];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
571 dvd_title = guiIntfStruct.DVD.current_title;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
572 dvd_chapter = guiIntfStruct.DVD.current_chapter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
573 dvd_angle = guiIntfStruct.DVD.current_angle;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
574 sprintf(tmp,"dvd://%d", guiIntfStruct.Title);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
575 guiSetFilename(guiIntfStruct.Filename, tmp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
576 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
577 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
578 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
579 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
580 if(guiIntfStruct.Filename)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
581 filename = strdup(guiIntfStruct.Filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
582 else if(filename)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
583 strcpy(guiIntfStruct.Filename, filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
584 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
585 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
586 case guiSetAudioOnly:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
587 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
588 guiIntfStruct.AudioOnly = (int) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
589 if(IsWindowVisible(mygui->subwindow))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
590 ShowWindow(mygui->subwindow, SW_HIDE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
591 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
592 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
593 case guiSetDemuxer:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
594 guiIntfStruct.demuxer = (void *) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
595 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
596 case guiSetValues:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
597 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
598 guiIntfStruct.sh_video = arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
599 if (arg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
600 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
601 sh_video_t *sh = (sh_video_t *)arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
602 codecname = sh->codec->name;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
603 guiIntfStruct.FPS = sh->fps;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
604
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
605 /* we have video, show the subwindow */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
606 if(!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
607 ShowWindow(mygui->subwindow, SW_SHOWNORMAL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
608 if(WinID == -1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
609 update_subwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
610
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
611 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
612 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
613 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
614 case guiSetShVideo:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
615 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
616 guiIntfStruct.MovieWidth = vo_dwidth;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
617 guiIntfStruct.MovieHeight = vo_dheight;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
618
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
619 sub_aspect = (float)guiIntfStruct.MovieWidth/guiIntfStruct.MovieHeight;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
620 if(WinID != -1)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
621 update_subwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
622 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
623 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
624 case guiSetStream:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
625 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
626 guiIntfStruct.StreamType = stream->type;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
627 switch(stream->type)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
628 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
629 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
630 case STREAMTYPE_DVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
631 guiGetEvent(guiSetDVD, (char *) stream->priv);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
632 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
633 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
634 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
635 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
636 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
637 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
638 case guiSetDVD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
639 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
640 guiIntfStruct.DVD.titles = dvdp->vmg_file->tt_srpt->nr_of_srpts;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
641 guiIntfStruct.DVD.chapters = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
642 guiIntfStruct.DVD.angles = dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
643 guiIntfStruct.DVD.nr_of_audio_channels = dvdp->nr_of_channels;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
644 memcpy(guiIntfStruct.DVD.audio_streams, dvdp->audio_streams, sizeof(dvdp->audio_streams));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
645 guiIntfStruct.DVD.nr_of_subtitles = dvdp->nr_of_subtitles;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
646 memcpy(guiIntfStruct.DVD.subtitles, dvdp->subtitles, sizeof(dvdp->subtitles));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
647 guiIntfStruct.DVD.current_title = dvd_title + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
648 guiIntfStruct.DVD.current_chapter = dvd_chapter + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
649 guiIntfStruct.DVD.current_angle = dvd_angle + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
650 guiIntfStruct.Track = dvd_title + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
651 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
652 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
653 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
654 case guiReDraw:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
655 mygui->updatedisplay(mygui, mygui->mainwindow);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
656 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
657 case guiSetAfilter:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
658 guiIntfStruct.afilter = (void *) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
659 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
660 case guiCEvent:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
661 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
662 guiIntfStruct.Playing = (int) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
663 switch (guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
664 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
665 case guiSetPlay:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
666 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
667 guiIntfStruct.Playing = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
668 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
669 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
670 case guiSetStop:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
671 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
672 guiIntfStruct.Playing = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
673 if(movie_aspect >= 0)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
674 movie_aspect = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
675 update_subwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
676 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
677 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
678 case guiSetPause:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
679 guiIntfStruct.Playing = 2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
680 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
681 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
682 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
683 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
684 case guiIEvent:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
685 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
686 mp_msg(MSGT_GPLAYER,MSGL_V, "cmd: %d\n", (int) arg);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
687 /* MPlayer asks us to quit */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
688 switch((int) arg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
689 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
690 case MP_CMD_GUI_FULLSCREEN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
691 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
692 if(!guiIntfStruct.sh_video) break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
693 video_out->control(VOCTRL_FULLSCREEN, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
694
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
695 /* no WinID, keep the sub window hidden */
18947
06ab2099c10e OpenGL outputs actually support WinID, not to mention that showing the option
reimar
parents: 18914
diff changeset
696 if(!sub_window)
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
697 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
698
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
699 if(vo_fs)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
700 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
701 WinID = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
702 ShowWindow(mygui->subwindow, SW_HIDE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
703 while(ShowCursor(FALSE) >= 0){}
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
704 } else {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
705 WinID = mygui->subwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
706 ShowWindow(mygui->subwindow, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
707 while(ShowCursor(TRUE) <= 0){}
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
708 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
709 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
710 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
711 case MP_CMD_QUIT:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
712 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
713 mygui->uninit(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
714 free(mygui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
715 mygui = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
716 exit_player("Done");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
717 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
718 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
719 case MP_CMD_GUI_STOP:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
720 guiGetEvent(guiCEvent, (void *) guiSetStop);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
721 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
722 case MP_CMD_GUI_PLAY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
723 guiGetEvent(guiCEvent, (void *) guiSetPlay);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
724 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
725 case MP_CMD_GUI_SKINBROWSER:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
726 if(vo_fs) guiSetEvent(evFullScreen);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
727 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_SKINBROWSER, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
728 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
729 case MP_CMD_GUI_PLAYLIST:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
730 if(vo_fs) guiSetEvent(evFullScreen);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
731 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PLAYLIST, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
732 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
733 case MP_CMD_GUI_PREFERENCES:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
734 if(vo_fs) guiSetEvent(evFullScreen);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
735 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) ID_PREFS, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
736 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
737 case MP_CMD_GUI_LOADFILE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
738 if(vo_fs) guiSetEvent(evFullScreen);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
739 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDFILE_OPEN, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
740 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
741 #ifdef USE_SUB
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
742 case MP_CMD_GUI_LOADSUBTITLE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
743 if(vo_fs) guiSetEvent(evFullScreen);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
744 PostMessage(mygui->mainwindow, WM_COMMAND, (WPARAM) IDSUBTITLE_OPEN, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
745 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
746 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
747 default:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
748 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
749 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
750 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
751 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
752 case guiSetFileName:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
753 if (arg) guiIntfStruct.Filename = (char *) arg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
754 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
755 case guiSetDefaults:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
756 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
757 audio_id = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
758 video_id = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
759 dvdsub_id = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
760 vobsub_id = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
761 stream_cache_size = -1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
762 autosync = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
763 vcd_track = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
764 dvd_title = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
765 force_fps = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
766 if(!mygui->playlist->tracks) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
767 filename = guiIntfStruct.Filename = mygui->playlist->tracks[mygui->playlist->current]->filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
768 guiIntfStruct.Track = mygui->playlist->current + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
769 if(gtkAONorm) greplace(&af_cfg.list, "volnorm", "volnorm");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
770 if(gtkAOExtraStereo)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
771 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
772 char *name = malloc(12 + 20 + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
773 snprintf(name, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
774 name[12 + 20] = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
775 greplace(&af_cfg.list, "extrastereo", name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
776 free(name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
777 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
778 if(gtkCacheOn) stream_cache_size = gtkCacheSize;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
779 if(gtkAutoSyncOn) autosync = gtkAutoSync;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
780 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
781 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
782 case guiSetVolume:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
783 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
784 if(audio_out)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
785 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
786 /* Some audio_out drivers do not support balance e.g. dsound */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
787 /* FIXME this algo is not correct */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
788 float l, r;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
789 mixer_getvolume(&mixer, &l, &r);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
790 guiIntfStruct.Volume = (r > l ? r : l); /* max(r,l) */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
791 if (r != l)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
792 guiIntfStruct.Balance = ((r-l) + 100.0f) * 0.5f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
793 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
794 guiIntfStruct.Balance = 50.0f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
795 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
796 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
797 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
798 default:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
799 mp_msg(MSGT_GPLAYER, MSGL_ERR, "[GUI] GOT UNHANDLED EVENT %i\n", type);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
800 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
801 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
802 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
803
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
804 /* This function adds/inserts one file into the gui playlist */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
805 int import_file_into_gui(char *pathname, int insert)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
806 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
807 char filename[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
808 char *filepart = filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
809
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
810 if (strstr(pathname, "://"))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
811 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
812 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding special %s\n", pathname);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
813 mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
814 return 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
815 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
816 if (GetFullPathName(pathname, MAX_PATH, filename, &filepart))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
817 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
818 if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
819 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
820 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
821 mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
822 return 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
823 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
824 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
825 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
826 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
827
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
828 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
829 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
830
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
831 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
832 by either:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
833 - overwriting gui pl (enqueue=0) */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
834
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
835 int import_initial_playtree_into_gui(play_tree_t *my_playtree, m_config_t *config, int enqueue)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
836 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
837 play_tree_iter_t *my_pt_iter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
838 int result = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
839
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
840 if(!mygui) guiInit();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
841
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
842 if((my_pt_iter = pt_iter_create(&my_playtree, config)))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
843 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
844 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
845 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
846 if (parse_filename(filename, my_playtree, config, 0))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
847 result = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
848 else if (import_file_into_gui(filename, 0)) /* Add it to end of list */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
849 result = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
850 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
851 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
852 mplGotoTheNext = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
853
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
854 if (result)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
855 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
856 mygui->playlist->current = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
857 filename = mygui->playlist->tracks[0]->filename;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
858 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
859 return result;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
860 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
861
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
862 /* This function imports and inserts an playtree, that is created "on the fly", for example by
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
863 parsing some MOV-Reference-File; or by loading an playlist with "File Open"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
864 The file which contained the playlist is thereby replaced with it's contents. */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
865
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
866 int import_playtree_playlist_into_gui(play_tree_t *my_playtree, m_config_t *config)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
867 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
868 play_tree_iter_t *my_pt_iter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
869 int result = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
870
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
871 if((my_pt_iter = pt_iter_create(&my_playtree, config)))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
872 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
873 while ((filename = pt_iter_get_next_file(my_pt_iter)) != NULL)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
874 if (import_file_into_gui(filename, 1)) /* insert it into the list and set plCurrent = new item */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
875 result = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
876 pt_iter_destroy(&my_pt_iter);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
877 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
878 filename = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
879 return result;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
880 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
881
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
882 inline void gtkMessageBox(int type, const char *str)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
883 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
884 if (type & GTK_MB_FATAL)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
885 MessageBox(NULL, str, "MPlayer GUI for Windows Error", MB_OK | MB_ICONERROR);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
886
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
887 fprintf(stderr, "[GUI] MessageBox: %s\n", str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
888 fflush(stderr);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
889 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
890
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
891 void guiMessageBox(int level, char *str)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
892 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
893 switch(level)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
894 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
895 case MSGL_FATAL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
896 gtkMessageBox(GTK_MB_FATAL | GTK_MB_SIMPLE, str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
897 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
898 case MSGL_ERR:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
899 gtkMessageBox(GTK_MB_ERROR | GTK_MB_SIMPLE, str);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
900 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
901 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
902 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
903
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
904 static int update_subwindow(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
905 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
906 int x,y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
907 RECT rd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
908 WINDOWPOS wp;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
909
18947
06ab2099c10e OpenGL outputs actually support WinID, not to mention that showing the option
reimar
parents: 18914
diff changeset
910 if(!sub_window)
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
911 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
912 WinID = -1; // so far only directx supports WinID in windows
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
913
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
914 if(IsWindowVisible(mygui->subwindow) && guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
915 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
916 ShowWindow(mygui->subwindow, SW_HIDE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
917 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
918 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
919 else if(guiIntfStruct.AudioOnly)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
920 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
921 else ShowWindow(mygui->subwindow, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
922 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
923
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
924 /* we've come out of fullscreen at the end of file */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
925 if((!IsWindowVisible(mygui->subwindow) || IsIconic(mygui->subwindow)) && !guiIntfStruct.AudioOnly)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
926 ShowWindow(mygui->subwindow, SW_SHOWNORMAL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
927
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
928 /* get our current window coordinates */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
929 GetWindowRect(mygui->subwindow, &rd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
930 x = rd.left;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
931 y = rd.top;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
932
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
933 if(!guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
934 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
935 window *desc = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
936 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
937
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
938 for (i=0; i<mygui->skin->windowcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
939 if(mygui->skin->windows[i]->type == wiSub)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
940 desc = mygui->skin->windows[i];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
941
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
942 rd.right = rd.left+desc->base->bitmap[0]->width;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
943 rd.bottom = rd.top+desc->base->bitmap[0]->height;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
944 sub_aspect = (float)(rd.right-rd.left)/(rd.bottom-rd.top);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
945 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
946 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
947 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
948 rd.right = rd.left+guiIntfStruct.MovieWidth;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
949 rd.bottom = rd.top+guiIntfStruct.MovieHeight;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
950
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
951 if (movie_aspect > 0.0) // forced aspect from the cmdline
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
952 sub_aspect = movie_aspect;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
953 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
954
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
955 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
956 SetWindowPos(mygui->subwindow, HWND_NOTOPMOST, x, y, rd.right-rd.left, rd.bottom-rd.top, SWP_NOOWNERZORDER);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
957
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
958 wp.hwnd = mygui->subwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
959 wp.x = rd.left;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
960 wp.y = rd.top;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
961 wp.cx = rd.right-rd.left;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
962 wp.cy = rd.bottom-rd.top;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
963 wp.flags = SWP_NOOWNERZORDER | SWP_SHOWWINDOW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
964
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
965 /* erase the bitmap image if there's video */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
966 if(guiIntfStruct.Playing != 0 && guiIntfStruct.sh_video)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
967 SendMessage(mygui->subwindow, WM_ERASEBKGND, (WPARAM)GetDC(mygui->subwindow), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
968
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
969 /* reset the window aspect */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
970 SendMessage(mygui->subwindow, WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
971 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
972 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
973
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
974 void guiEventHandling(void) {}