2 * MPlayer GUI for Win32
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de>
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com>
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
7 * This file is part of MPlayer.
9 * MPlayer is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * MPlayer is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include "gui/interface.h"
31 #include "codec-cfg.h"
32 #include "stream/stream.h"
33 #include "libmpdemux/demuxer.h"
34 #include "libmpdemux/stheader.h"
36 #include "stream/stream_dvd.h"
38 #include "input/input.h"
39 #include "libvo/video_out.h"
40 #include "libao2/audio_out.h"
41 #include "access_mpcontext.h"
42 #include "libmpcodecs/vd.h"
43 #include "gui/mplayer/gmplayer.h"
48 #include <cdio/cdio.h>
52 extern af_cfg_t af_cfg
;
55 char *skinName
= NULL
;
56 char *codecname
= NULL
;
57 int mplGotoTheNext
= 1;
58 static gui_t
*mygui
= NULL
;
59 static int update_subwindow(void);
62 static HANDLE hThread
;
63 static unsigned threadId
;
64 const ao_functions_t
*audio_out
= NULL
;
65 const vo_functions_t
*video_out
= NULL
;
66 mixer_t
*mixer
= NULL
;
68 /* test for playlist files, no need to specify -playlist on the commandline.
69 * add any conceivable playlist extensions here.
72 int parse_filename(char *file
, play_tree_t
*playtree
, m_config_t
*mconfig
, int clear
)
75 mygui
->playlist
->clear_playlist(mygui
->playlist
);
77 if(strstr(file
, ".m3u") || strstr(file
, ".pls"))
79 playtree
= parse_playlist_file(file
);
80 import_playtree_playlist_into_gui(playtree
, mconfig
);
87 * \brief this actually creates a new list containing only one element...
89 void gaddlist( char ***list
, const char *entry
)
95 for (i
=0; (*list
)[i
]; i
++) free((*list
)[i
]);
99 *list
= malloc(2 * sizeof(char **));
100 (*list
)[0] = gstrdup(entry
);
104 char *gstrdup(const char *str
)
106 if (!str
) return NULL
;
111 * \brief this replaces a string starting with search by replace.
112 * If not found, replace is appended.
114 void greplace(char ***list
, char *search
, char *replace
)
117 int len
= (search
) ? strlen(search
) : 0;
121 for (i
= 0; (*list
)[i
]; i
++)
123 if (search
&& (!strncmp((*list
)[i
], search
, len
)))
126 (*list
)[i
] = gstrdup(replace
);
130 *list
= realloc(*list
, (i
+ 2) * sizeof(char *));
133 *list
= malloc(2 * sizeof(char *));
135 (*list
)[i
] = gstrdup(replace
);
136 (*list
)[i
+ 1] = NULL
;
139 /* this function gets called by the gui to update mplayer */
140 static void guiSetEvent(int event
)
142 if(guiIntfStruct
.mpcontext
)
143 mixer
= mpctx_get_mixer(guiIntfStruct
.mpcontext
);
148 case evPlaySwitchToPause
:
149 case evPauseSwitchToPlay
:
155 #ifdef CONFIG_DVDREAD
158 static char dvdname
[MAX_PATH
];
159 guiIntfStruct
.DVD
.current_title
= dvd_title
;
160 guiIntfStruct
.DVD
.current_chapter
= dvd_chapter
;
161 guiIntfStruct
.DVD
.current_angle
= dvd_angle
;
162 guiIntfStruct
.DiskChanged
= 1;
164 mplSetFileName(NULL
, dvd_device
, STREAMTYPE_DVD
);
166 strcat(dvdname
, "DVD Movie");
167 GetVolumeInformation(dvd_device
, dvdname
, MAX_PATH
, NULL
, NULL
, NULL
, NULL
, 0);
169 mp_msg(MSGT_GPLAYER
, MSGL_V
, "Opening DVD %s -> %s\n", dvd_device
, dvdname
);
170 guiGetEvent(guiSetParameters
, (char *) STREAMTYPE_DVD
);
171 mygui
->playlist
->clear_playlist(mygui
->playlist
);
172 mygui
->playlist
->add_track(mygui
->playlist
, filename
, NULL
, dvdname
, 0);
173 mygui
->startplay(mygui
);
177 #ifdef CONFIG_LIBCDIO
183 CdIo_t
*p_cdio
= cdio_open(NULL
, DRIVER_UNKNOWN
);
186 if(p_cdio
== NULL
) printf("Couldn't find a driver.\n");
187 i_tracks
= cdio_get_num_tracks(p_cdio
);
189 mygui
->playlist
->clear_playlist(mygui
->playlist
);
190 for(i
=0;i
<i_tracks
;i
++)
192 sprintf(track
, "cdda://%d", i
+1);
193 sprintf(trackname
, "Track %d", i
+1);
194 mygui
->playlist
->add_track(mygui
->playlist
, track
, NULL
, trackname
, 0);
196 cdio_destroy(p_cdio
);
197 mygui
->startplay(mygui
);
202 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen"));
206 /* We are asking mplayer to exit, later it will ask us after uninit is made
207 this should be the only safe way to quit */
208 mygui
->activewidget
= NULL
;
209 mp_input_queue_cmd(mp_input_parse_cmd("quit"));
213 if(guiIntfStruct
.Playing
)
214 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
216 case evSetMoviePosition
:
218 rel_seek_secs
= guiIntfStruct
.Position
/ 100.0f
;
224 rel_seek_secs
= 10.0f
;
228 case evBackward10sec
:
230 rel_seek_secs
= -10.0f
;
239 if (guiIntfStruct
.Playing
== 0)
242 if (guiIntfStruct
.Balance
== 50.0f
)
243 mixer_setvolume(mixer
, guiIntfStruct
.Volume
, guiIntfStruct
.Volume
);
245 l
= guiIntfStruct
.Volume
* ((100.0f
- guiIntfStruct
.Balance
) / 50.0f
);
246 r
= guiIntfStruct
.Volume
* ((guiIntfStruct
.Balance
) / 50.0f
);
248 if (l
> guiIntfStruct
.Volume
) l
=guiIntfStruct
.Volume
;
249 if (r
> guiIntfStruct
.Volume
) r
=guiIntfStruct
.Volume
;
250 mixer_setvolume(mixer
, l
, r
);
251 /* Check for balance support on mixer - there is a better way ?? */
254 mixer_getvolume(mixer
, &l
, &r
);
257 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Mixer doesn't support balanced audio\n");
258 mixer_setvolume(mixer
, guiIntfStruct
.Volume
, guiIntfStruct
.Volume
);
259 guiIntfStruct
.Balance
= 50.0f
;
266 mp_cmd_t
* cmd
= calloc(1, sizeof(*cmd
));
268 cmd
->name
=strdup("mute");
269 mp_input_queue_cmd(cmd
);
275 switch(guiIntfStruct
.StreamType
)
277 #ifdef CONFIG_DVDREAD
280 guiIntfStruct
.Title
= guiIntfStruct
.DVD
.current_title
;
281 guiIntfStruct
.Chapter
= guiIntfStruct
.DVD
.current_chapter
;
282 guiIntfStruct
.Angle
= guiIntfStruct
.DVD
.current_angle
;
283 guiIntfStruct
.DiskChanged
= 1;
284 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
290 guiIntfStruct
.FilenameChanged
= guiIntfStruct
.NewPlay
= 1;
291 update_playlistwindow();
292 mplGotoTheNext
= guiIntfStruct
.Playing
? 0 : 1;
293 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
294 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
311 if((!guiIntfStruct
.Filename
) || (guiIntfStruct
.Filename
[0] == 0))
314 if(guiIntfStruct
.Playing
> 0)
319 guiIntfStruct
.NewPlay
= 1;
320 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
323 void mplPause( void )
325 if(!guiIntfStruct
.Playing
) return;
327 if(guiIntfStruct
.Playing
== 1)
329 mp_cmd_t
* cmd
= calloc(1, sizeof(*cmd
));
330 cmd
->id
=MP_CMD_PAUSE
;
331 cmd
->name
=strdup("pause");
332 mp_input_queue_cmd(cmd
);
333 } else guiIntfStruct
.Playing
= 1;
338 if(guiIntfStruct
.Playing
== 2) return;
339 switch(guiIntfStruct
.StreamType
)
341 #ifdef CONFIG_DVDREAD
343 if(guiIntfStruct
.DVD
.current_chapter
== (guiIntfStruct
.DVD
.chapters
- 1))
345 guiIntfStruct
.DVD
.current_chapter
++;
349 if(mygui
->playlist
->current
== (mygui
->playlist
->trackcount
- 1))
351 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)++]->filename
,
355 mygui
->startplay(mygui
);
360 if(guiIntfStruct
.Playing
== 2) return;
361 switch(guiIntfStruct
.StreamType
)
363 #ifdef CONFIG_DVDREAD
365 if(guiIntfStruct
.DVD
.current_chapter
== 1)
367 guiIntfStruct
.DVD
.current_chapter
--;
371 if(mygui
->playlist
->current
== 0)
373 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)--]->filename
,
377 mygui
->startplay(mygui
);
382 if(!mplGotoTheNext
&& guiIntfStruct
.Playing
)
388 if(mplGotoTheNext
&& guiIntfStruct
.Playing
&&
389 (mygui
->playlist
->current
< (mygui
->playlist
->trackcount
- 1)) &&
390 guiIntfStruct
.StreamType
!= STREAMTYPE_DVD
&&
391 guiIntfStruct
.StreamType
!= STREAMTYPE_DVDNAV
)
393 /* we've finished this file, reset the aspect */
394 if(movie_aspect
>= 0)
397 mplGotoTheNext
= guiIntfStruct
.FilenameChanged
= guiIntfStruct
.NewPlay
= 1;
398 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)++]->filename
, STREAMTYPE_STREAM
);
399 //sprintf(guiIntfStruct.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename);
402 if(guiIntfStruct
.FilenameChanged
&& guiIntfStruct
.NewPlay
)
405 guiIntfStruct
.TimeSec
= 0;
406 guiIntfStruct
.Position
= 0;
407 guiIntfStruct
.AudioType
= 0;
409 #ifdef CONFIG_DVDREAD
410 guiIntfStruct
.DVD
.current_title
= 1;
411 guiIntfStruct
.DVD
.current_chapter
= 1;
412 guiIntfStruct
.DVD
.current_angle
= 1;
415 if (mygui
->playlist
->current
== (mygui
->playlist
->trackcount
- 1))
416 mygui
->playlist
->current
= 0;
419 if(style
== WS_VISIBLE
| WS_POPUP
)
421 style
= WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
;
422 SetWindowLong(mygui
->subwindow
, GWL_STYLE
, style
);
424 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
427 void mplSetFileName(char *dir
, char *name
, int type
)
431 guiSetFilename(guiIntfStruct
.Filename
, name
)
433 guiSetDF(guiIntfStruct
.Filename
, dir
, name
);
435 guiIntfStruct
.StreamType
= type
;
436 free((void **) &guiIntfStruct
.AudioFile
);
437 free((void **) &guiIntfStruct
.Subtitlename
);
440 void mplFullScreen( void )
442 if(!guiIntfStruct
.sh_video
) return;
446 if(!fullscreen
&& IsWindowVisible(mygui
->subwindow
) && !IsIconic(mygui
->subwindow
))
447 GetWindowRect(mygui
->subwindow
, &old_rect
);
452 style
= WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
;
455 style
= WS_VISIBLE
| WS_POPUP
;
457 SetWindowLong(mygui
->subwindow
, GWL_STYLE
, style
);
460 video_out
->control(VOCTRL_FULLSCREEN
, 0);
461 if(sub_window
) ShowWindow(mygui
->subwindow
, SW_SHOW
);
464 static unsigned __stdcall
GuiThread(void* param
)
468 if(!skinName
) skinName
= strdup("Blue");
469 if(!mygui
) mygui
= create_gui(get_path("skins"), skinName
, guiSetEvent
);
470 if(!mygui
) exit_player(EXIT_ERROR
);
472 if(autosync
&& autosync
!= gtkAutoSync
)
475 gtkAutoSync
= autosync
;
478 while(GetMessage(&msg
, NULL
, 0, 0))
480 TranslateMessage(&msg
);
481 DispatchMessage(&msg
);
483 fprintf(stderr
, "[GUI] GUI thread terminated.\n");
490 memset(&guiIntfStruct
, 0, sizeof(guiIntfStruct
));
491 /* Create The gui thread */
494 hThread
= _beginthreadex(NULL
, 0, GuiThread
, NULL
, 0, &threadId
);
495 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Creating GUI Thread 0x%04x\n", threadId
);
498 /* Wait until the gui is created */
499 while(!mygui
) Sleep(100);
500 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] GUI thread started.\n");
507 fprintf(stderr
, "[GUI] Closed by main mplayer window\n");
509 PostThreadMessage(threadId
, WM_QUIT
, 0, 0);
510 WaitForSingleObject(hThread
, INFINITE
);
511 CloseHandle(hThread
);
512 mygui
->uninit(mygui
);
516 /* Remove tray icon */
517 Shell_NotifyIcon(NIM_DELETE
, &nid
);
521 /* this function gets called by mplayer to update the gui */
522 int guiGetEvent(int type
, void *arg
)
524 stream_t
*stream
= arg
;
525 #ifdef CONFIG_DVDREAD
526 dvd_priv_t
*dvdp
= arg
;
528 if(!mygui
|| !mygui
->skin
) return 0;
530 if(guiIntfStruct
.mpcontext
)
532 audio_out
= mpctx_get_audio_out(guiIntfStruct
.mpcontext
);
533 video_out
= mpctx_get_video_out(guiIntfStruct
.mpcontext
);
534 mixer
= mpctx_get_mixer(guiIntfStruct
.mpcontext
);
535 playtree
= mpctx_get_playtree_iter(guiIntfStruct
.mpcontext
);
540 case guiSetFileFormat
:
541 guiIntfStruct
.FileFormat
= (int) arg
;
543 case guiSetParameters
:
545 guiGetEvent(guiSetDefaults
, NULL
);
546 guiIntfStruct
.DiskChanged
= 0;
547 guiIntfStruct
.FilenameChanged
= 0;
548 guiIntfStruct
.NewPlay
= 0;
549 switch(guiIntfStruct
.StreamType
)
551 case STREAMTYPE_PLAYLIST
:
553 #ifdef CONFIG_DVDREAD
557 dvd_title
= guiIntfStruct
.DVD
.current_title
;
558 dvd_chapter
= guiIntfStruct
.DVD
.current_chapter
;
559 dvd_angle
= guiIntfStruct
.DVD
.current_angle
;
560 sprintf(tmp
,"dvd://%d", guiIntfStruct
.Title
);
561 guiSetFilename(guiIntfStruct
.Filename
, tmp
);
566 if(guiIntfStruct
.Filename
)
567 filename
= strdup(guiIntfStruct
.Filename
);
569 strcpy(guiIntfStruct
.Filename
, filename
);
572 case guiSetAudioOnly
:
574 guiIntfStruct
.AudioOnly
= (int) arg
;
575 if(IsWindowVisible(mygui
->subwindow
))
576 ShowWindow(mygui
->subwindow
, SW_HIDE
);
580 guiIntfStruct
.mpcontext
= arg
;
583 guiIntfStruct
.demuxer
= arg
;
587 guiIntfStruct
.sh_video
= arg
;
590 sh_video_t
*sh
= arg
;
591 codecname
= sh
->codec
->name
;
592 guiIntfStruct
.FPS
= sh
->fps
;
594 /* we have video, show the subwindow */
595 if(!IsWindowVisible(mygui
->subwindow
) || IsIconic(mygui
->subwindow
))
596 ShowWindow(mygui
->subwindow
, SW_SHOWNORMAL
);
605 guiIntfStruct
.MovieWidth
= vo_dwidth
;
606 guiIntfStruct
.MovieHeight
= vo_dheight
;
608 sub_aspect
= (float)guiIntfStruct
.MovieWidth
/guiIntfStruct
.MovieHeight
;
615 guiIntfStruct
.StreamType
= stream
->type
;
618 #ifdef CONFIG_DVDREAD
620 guiGetEvent(guiSetDVD
, (char *) stream
->priv
);
626 #ifdef CONFIG_DVDREAD
629 guiIntfStruct
.DVD
.titles
= dvdp
->vmg_file
->tt_srpt
->nr_of_srpts
;
630 guiIntfStruct
.DVD
.chapters
= dvdp
->vmg_file
->tt_srpt
->title
[dvd_title
].nr_of_ptts
;
631 guiIntfStruct
.DVD
.angles
= dvdp
->vmg_file
->tt_srpt
->title
[dvd_title
].nr_of_angles
;
632 guiIntfStruct
.DVD
.nr_of_audio_channels
= dvdp
->nr_of_channels
;
633 memcpy(guiIntfStruct
.DVD
.audio_streams
, dvdp
->audio_streams
, sizeof(dvdp
->audio_streams
));
634 guiIntfStruct
.DVD
.nr_of_subtitles
= dvdp
->nr_of_subtitles
;
635 memcpy(guiIntfStruct
.DVD
.subtitles
, dvdp
->subtitles
, sizeof(dvdp
->subtitles
));
636 guiIntfStruct
.DVD
.current_title
= dvd_title
+ 1;
637 guiIntfStruct
.DVD
.current_chapter
= dvd_chapter
+ 1;
638 guiIntfStruct
.DVD
.current_angle
= dvd_angle
+ 1;
639 guiIntfStruct
.Track
= dvd_title
+ 1;
644 mygui
->updatedisplay(mygui
, mygui
->mainwindow
);
647 guiIntfStruct
.afilter
= arg
;
651 guiIntfStruct
.Playing
= (int) arg
;
652 switch (guiIntfStruct
.Playing
)
656 guiIntfStruct
.Playing
= 1;
661 guiIntfStruct
.Playing
= 0;
662 if(movie_aspect
>= 0)
668 guiIntfStruct
.Playing
= 2;
675 mp_msg(MSGT_GPLAYER
,MSGL_V
, "cmd: %d\n", (int) arg
);
676 /* MPlayer asks us to quit */
679 case MP_CMD_GUI_FULLSCREEN
:
684 mygui
->uninit(mygui
);
687 exit_player(EXIT_QUIT
);
690 case MP_CMD_GUI_STOP
:
691 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
693 case MP_CMD_GUI_PLAY
:
694 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
696 case MP_CMD_GUI_SKINBROWSER
:
697 if(fullscreen
) guiSetEvent(evFullScreen
);
698 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_SKINBROWSER
, 0);
700 case MP_CMD_GUI_PLAYLIST
:
701 if(fullscreen
) guiSetEvent(evFullScreen
);
702 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_PLAYLIST
, 0);
704 case MP_CMD_GUI_PREFERENCES
:
705 if(fullscreen
) guiSetEvent(evFullScreen
);
706 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_PREFS
, 0);
708 case MP_CMD_GUI_LOADFILE
:
709 if(fullscreen
) guiSetEvent(evFullScreen
);
710 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) IDFILE_OPEN
, 0);
712 case MP_CMD_GUI_LOADSUBTITLE
:
713 if(fullscreen
) guiSetEvent(evFullScreen
);
714 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) IDSUBTITLE_OPEN
, 0);
722 if (arg
) guiIntfStruct
.Filename
= arg
;
730 stream_cache_size
= -1;
735 if(!mygui
->playlist
->tracks
) return 0;
736 filename
= guiIntfStruct
.Filename
= mygui
->playlist
->tracks
[mygui
->playlist
->current
]->filename
;
737 guiIntfStruct
.Track
= mygui
->playlist
->current
+ 1;
738 if(gtkAONorm
) greplace(&af_cfg
.list
, "volnorm", "volnorm");
741 char *name
= malloc(12 + 20 + 1);
742 snprintf(name
, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul
);
744 greplace(&af_cfg
.list
, "extrastereo", name
);
747 if(gtkCacheOn
) stream_cache_size
= gtkCacheSize
;
748 if(gtkAutoSyncOn
) autosync
= gtkAutoSync
;
755 /* Some audio_out drivers do not support balance e.g. dsound */
756 /* FIXME this algo is not correct */
758 mixer_getvolume(mixer
, &l
, &r
);
759 guiIntfStruct
.Volume
= (r
> l
? r
: l
); /* max(r,l) */
761 guiIntfStruct
.Balance
= ((r
-l
) + 100.0f
) * 0.5f
;
763 guiIntfStruct
.Balance
= 50.0f
;
768 mp_msg(MSGT_GPLAYER
, MSGL_ERR
, "[GUI] GOT UNHANDLED EVENT %i\n", type
);
773 /* This function adds/inserts one file into the gui playlist */
774 int import_file_into_gui(char *pathname
, int insert
)
776 char filename
[MAX_PATH
];
777 char *filepart
= filename
;
779 if (strstr(pathname
, "://"))
781 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Adding special %s\n", pathname
);
782 mygui
->playlist
->add_track(mygui
->playlist
, pathname
, NULL
, NULL
, 0);
785 if (GetFullPathName(pathname
, MAX_PATH
, filename
, &filepart
))
787 if (!(GetFileAttributes(filename
) & FILE_ATTRIBUTE_DIRECTORY
))
789 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Adding filename: %s - fullpath: %s\n", filepart
, filename
);
790 mygui
->playlist
->add_track(mygui
->playlist
, filename
, NULL
, filepart
, 0);
794 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Cannot add %s\n", filename
);
800 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist
802 - overwriting gui pl (enqueue=0) */
804 int import_initial_playtree_into_gui(play_tree_t
*my_playtree
, m_config_t
*config
, int enqueue
)
806 play_tree_iter_t
*my_pt_iter
= NULL
;
809 if(!mygui
) guiInit();
811 if((my_pt_iter
= pt_iter_create(&my_playtree
, config
)))
813 while ((filename
= pt_iter_get_next_file(my_pt_iter
)) != NULL
)
815 if (parse_filename(filename
, my_playtree
, config
, 0))
817 else if (import_file_into_gui(filename
, 0)) /* Add it to end of list */
825 mygui
->playlist
->current
= 0;
826 filename
= mygui
->playlist
->tracks
[0]->filename
;
831 /* This function imports and inserts an playtree, that is created "on the fly", for example by
832 parsing some MOV-Reference-File; or by loading an playlist with "File Open"
833 The file which contained the playlist is thereby replaced with it's contents. */
835 int import_playtree_playlist_into_gui(play_tree_t
*my_playtree
, m_config_t
*config
)
837 play_tree_iter_t
*my_pt_iter
= NULL
;
840 if((my_pt_iter
= pt_iter_create(&my_playtree
, config
)))
842 while ((filename
= pt_iter_get_next_file(my_pt_iter
)) != NULL
)
843 if (import_file_into_gui(filename
, 1)) /* insert it into the list and set plCurrent = new item */
845 pt_iter_destroy(&my_pt_iter
);
851 inline void gtkMessageBox(int type
, const char *str
)
853 if (type
& GTK_MB_FATAL
)
854 MessageBox(NULL
, str
, "MPlayer GUI for Windows Error", MB_OK
| MB_ICONERROR
);
856 fprintf(stderr
, "[GUI] MessageBox: %s\n", str
);
860 void guiMessageBox(int level
, char *str
)
865 gtkMessageBox(GTK_MB_FATAL
| GTK_MB_SIMPLE
, str
);
868 gtkMessageBox(GTK_MB_ERROR
| GTK_MB_SIMPLE
, str
);
873 static int update_subwindow(void)
881 WinID
= -1; // so far only directx supports WinID in windows
883 if(IsWindowVisible(mygui
->subwindow
) && guiIntfStruct
.sh_video
&& guiIntfStruct
.Playing
)
885 ShowWindow(mygui
->subwindow
, SW_HIDE
);
888 else if(guiIntfStruct
.AudioOnly
)
890 else ShowWindow(mygui
->subwindow
, SW_SHOW
);
893 /* we've come out of fullscreen at the end of file */
894 if((!IsWindowVisible(mygui
->subwindow
) || IsIconic(mygui
->subwindow
)) && !guiIntfStruct
.AudioOnly
)
895 ShowWindow(mygui
->subwindow
, SW_SHOWNORMAL
);
897 /* get our current window coordinates */
898 GetWindowRect(mygui
->subwindow
, &rd
);
903 /* restore sub window position when coming out of fullscreen */
904 if(x
<= 0) x
= old_rect
.left
;
905 if(y
<= 0) y
= old_rect
.top
;
907 if(!guiIntfStruct
.Playing
)
912 for (i
=0; i
<mygui
->skin
->windowcount
; i
++)
913 if(mygui
->skin
->windows
[i
]->type
== wiSub
)
914 desc
= mygui
->skin
->windows
[i
];
916 rd
.right
= rd
.left
+desc
->base
->bitmap
[0]->width
;
917 rd
.bottom
= rd
.top
+desc
->base
->bitmap
[0]->height
;
918 sub_aspect
= (float)(rd
.right
-rd
.left
)/(rd
.bottom
-rd
.top
);
922 rd
.right
= rd
.left
+guiIntfStruct
.MovieWidth
;
923 rd
.bottom
= rd
.top
+guiIntfStruct
.MovieHeight
;
925 if (movie_aspect
> 0.0) // forced aspect from the cmdline
926 sub_aspect
= movie_aspect
;
930 AdjustWindowRect(&rd
, WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
, 0);
931 SetWindowPos(mygui
->subwindow
, 0, x
, y
, rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, SWP_NOOWNERZORDER
);
933 wp
.hwnd
= mygui
->subwindow
;
936 wp
.cx
= rd
.right
-rd
.left
;
937 wp
.cy
= rd
.bottom
-rd
.top
;
938 wp
.flags
= SWP_NOOWNERZORDER
| SWP_SHOWWINDOW
;
940 /* erase the bitmap image if there's video */
941 if(guiIntfStruct
.Playing
!= 0 && guiIntfStruct
.sh_video
)
942 SendMessage(mygui
->subwindow
, WM_ERASEBKGND
, (WPARAM
)GetDC(mygui
->subwindow
), 0);
944 /* reset the window aspect */
945 SendMessage(mygui
->subwindow
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&wp
);
949 void guiEventHandling(void) {}