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"
45 #include <cdio/cdio.h>
48 extern int abs_seek_pos
;
49 extern float rel_seek_secs
;
51 extern af_cfg_t af_cfg
;
54 char *skinName
= NULL
;
55 char *codecname
= NULL
;
56 int mplGotoTheNext
= 1;
57 static gui_t
*mygui
= NULL
;
58 static int update_subwindow(void);
61 static HANDLE hThread
;
62 static unsigned threadId
;
63 const ao_functions_t
*audio_out
= NULL
;
64 const vo_functions_t
*video_out
= NULL
;
65 mixer_t
*mixer
= NULL
;
67 /* test for playlist files, no need to specify -playlist on the commandline.
68 * add any conceivable playlist extensions here.
71 int parse_filename(char *file
, play_tree_t
*playtree
, m_config_t
*mconfig
, int clear
)
74 mygui
->playlist
->clear_playlist(mygui
->playlist
);
76 if(strstr(file
, ".m3u") || strstr(file
, ".pls"))
78 playtree
= parse_playlist_file(file
);
79 import_playtree_playlist_into_gui(playtree
, mconfig
);
86 * \brief this actually creates a new list containing only one element...
88 void gaddlist( char ***list
, const char *entry
)
94 for (i
=0; (*list
)[i
]; i
++) free((*list
)[i
]);
98 *list
= malloc(2 * sizeof(char **));
99 (*list
)[0] = gstrdup(entry
);
103 char *gstrdup(const char *str
)
105 if (!str
) return NULL
;
110 * \brief this replaces a string starting with search by replace.
111 * If not found, replace is appended.
113 void greplace(char ***list
, char *search
, char *replace
)
116 int len
= (search
) ? strlen(search
) : 0;
120 for (i
= 0; (*list
)[i
]; i
++)
122 if (search
&& (!strncmp((*list
)[i
], search
, len
)))
125 (*list
)[i
] = gstrdup(replace
);
129 *list
= realloc(*list
, (i
+ 2) * sizeof(char *));
132 *list
= malloc(2 * sizeof(char *));
134 (*list
)[i
] = gstrdup(replace
);
135 (*list
)[i
+ 1] = NULL
;
138 /* this function gets called by the gui to update mplayer */
139 static void guiSetEvent(int event
)
141 if(guiIntfStruct
.mpcontext
)
142 mixer
= mpctx_get_mixer(guiIntfStruct
.mpcontext
);
147 case evPlaySwitchToPause
:
148 case evPauseSwitchToPlay
:
154 #ifdef CONFIG_DVDREAD
157 static char dvdname
[MAX_PATH
];
158 guiIntfStruct
.DVD
.current_title
= dvd_title
;
159 guiIntfStruct
.DVD
.current_chapter
= dvd_chapter
;
160 guiIntfStruct
.DVD
.current_angle
= dvd_angle
;
161 guiIntfStruct
.DiskChanged
= 1;
163 mplSetFileName(NULL
, dvd_device
, STREAMTYPE_DVD
);
165 strcat(dvdname
, "DVD Movie");
166 GetVolumeInformation(dvd_device
, dvdname
, MAX_PATH
, NULL
, NULL
, NULL
, NULL
, 0);
168 mp_msg(MSGT_GPLAYER
, MSGL_V
, "Opening DVD %s -> %s\n", dvd_device
, dvdname
);
169 guiGetEvent(guiSetParameters
, (char *) STREAMTYPE_DVD
);
170 mygui
->playlist
->clear_playlist(mygui
->playlist
);
171 mygui
->playlist
->add_track(mygui
->playlist
, filename
, NULL
, dvdname
, 0);
172 mygui
->startplay(mygui
);
176 #ifdef CONFIG_LIBCDIO
182 CdIo_t
*p_cdio
= cdio_open(NULL
, DRIVER_UNKNOWN
);
185 if(p_cdio
== NULL
) printf("Couldn't find a driver.\n");
186 i_tracks
= cdio_get_num_tracks(p_cdio
);
188 mygui
->playlist
->clear_playlist(mygui
->playlist
);
189 for(i
=0;i
<i_tracks
;i
++)
191 sprintf(track
, "cdda://%d", i
+1);
192 sprintf(trackname
, "Track %d", i
+1);
193 mygui
->playlist
->add_track(mygui
->playlist
, track
, NULL
, trackname
, 0);
195 cdio_destroy(p_cdio
);
196 mygui
->startplay(mygui
);
201 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen"));
205 /* We are asking mplayer to exit, later it will ask us after uninit is made
206 this should be the only safe way to quit */
207 mygui
->activewidget
= NULL
;
208 mp_input_queue_cmd(mp_input_parse_cmd("quit"));
212 if(guiIntfStruct
.Playing
)
213 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
215 case evSetMoviePosition
:
217 rel_seek_secs
= guiIntfStruct
.Position
/ 100.0f
;
223 rel_seek_secs
= 10.0f
;
227 case evBackward10sec
:
229 rel_seek_secs
= -10.0f
;
238 if (guiIntfStruct
.Playing
== 0)
241 if (guiIntfStruct
.Balance
== 50.0f
)
242 mixer_setvolume(mixer
, guiIntfStruct
.Volume
, guiIntfStruct
.Volume
);
244 l
= guiIntfStruct
.Volume
* ((100.0f
- guiIntfStruct
.Balance
) / 50.0f
);
245 r
= guiIntfStruct
.Volume
* ((guiIntfStruct
.Balance
) / 50.0f
);
247 if (l
> guiIntfStruct
.Volume
) l
=guiIntfStruct
.Volume
;
248 if (r
> guiIntfStruct
.Volume
) r
=guiIntfStruct
.Volume
;
249 mixer_setvolume(mixer
, l
, r
);
250 /* Check for balance support on mixer - there is a better way ?? */
253 mixer_getvolume(mixer
, &l
, &r
);
256 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Mixer doesn't support balanced audio\n");
257 mixer_setvolume(mixer
, guiIntfStruct
.Volume
, guiIntfStruct
.Volume
);
258 guiIntfStruct
.Balance
= 50.0f
;
265 mp_cmd_t
* cmd
= calloc(1, sizeof(*cmd
));
267 cmd
->name
=strdup("mute");
268 mp_input_queue_cmd(cmd
);
274 switch(guiIntfStruct
.StreamType
)
276 #ifdef CONFIG_DVDREAD
279 guiIntfStruct
.Title
= guiIntfStruct
.DVD
.current_title
;
280 guiIntfStruct
.Chapter
= guiIntfStruct
.DVD
.current_chapter
;
281 guiIntfStruct
.Angle
= guiIntfStruct
.DVD
.current_angle
;
282 guiIntfStruct
.DiskChanged
= 1;
283 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
289 guiIntfStruct
.FilenameChanged
= guiIntfStruct
.NewPlay
= 1;
290 update_playlistwindow();
291 mplGotoTheNext
= guiIntfStruct
.Playing
? 0 : 1;
292 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
293 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
310 if((!guiIntfStruct
.Filename
) || (guiIntfStruct
.Filename
[0] == 0))
313 if(guiIntfStruct
.Playing
> 0)
318 guiIntfStruct
.NewPlay
= 1;
319 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
322 void mplPause( void )
324 if(!guiIntfStruct
.Playing
) return;
326 if(guiIntfStruct
.Playing
== 1)
328 mp_cmd_t
* cmd
= calloc(1, sizeof(*cmd
));
329 cmd
->id
=MP_CMD_PAUSE
;
330 cmd
->name
=strdup("pause");
331 mp_input_queue_cmd(cmd
);
332 } else guiIntfStruct
.Playing
= 1;
337 if(guiIntfStruct
.Playing
== 2) return;
338 switch(guiIntfStruct
.StreamType
)
340 #ifdef CONFIG_DVDREAD
342 if(guiIntfStruct
.DVD
.current_chapter
== (guiIntfStruct
.DVD
.chapters
- 1))
344 guiIntfStruct
.DVD
.current_chapter
++;
348 if(mygui
->playlist
->current
== (mygui
->playlist
->trackcount
- 1))
350 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)++]->filename
,
354 mygui
->startplay(mygui
);
359 if(guiIntfStruct
.Playing
== 2) return;
360 switch(guiIntfStruct
.StreamType
)
362 #ifdef CONFIG_DVDREAD
364 if(guiIntfStruct
.DVD
.current_chapter
== 1)
366 guiIntfStruct
.DVD
.current_chapter
--;
370 if(mygui
->playlist
->current
== 0)
372 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)--]->filename
,
376 mygui
->startplay(mygui
);
381 if(!mplGotoTheNext
&& guiIntfStruct
.Playing
)
387 if(mplGotoTheNext
&& guiIntfStruct
.Playing
&&
388 (mygui
->playlist
->current
< (mygui
->playlist
->trackcount
- 1)) &&
389 guiIntfStruct
.StreamType
!= STREAMTYPE_DVD
&&
390 guiIntfStruct
.StreamType
!= STREAMTYPE_DVDNAV
)
392 /* we've finished this file, reset the aspect */
393 if(movie_aspect
>= 0)
396 mplGotoTheNext
= guiIntfStruct
.FilenameChanged
= guiIntfStruct
.NewPlay
= 1;
397 mplSetFileName(NULL
, mygui
->playlist
->tracks
[(mygui
->playlist
->current
)++]->filename
, STREAMTYPE_STREAM
);
398 //sprintf(guiIntfStruct.Filename, mygui->playlist->tracks[(mygui->playlist->current)++]->filename);
401 if(guiIntfStruct
.FilenameChanged
&& guiIntfStruct
.NewPlay
)
404 guiIntfStruct
.TimeSec
= 0;
405 guiIntfStruct
.Position
= 0;
406 guiIntfStruct
.AudioType
= 0;
408 #ifdef CONFIG_DVDREAD
409 guiIntfStruct
.DVD
.current_title
= 1;
410 guiIntfStruct
.DVD
.current_chapter
= 1;
411 guiIntfStruct
.DVD
.current_angle
= 1;
414 if (mygui
->playlist
->current
== (mygui
->playlist
->trackcount
- 1))
415 mygui
->playlist
->current
= 0;
418 if(style
== WS_VISIBLE
| WS_POPUP
)
420 style
= WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
;
421 SetWindowLong(mygui
->subwindow
, GWL_STYLE
, style
);
423 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
426 void mplSetFileName(char *dir
, char *name
, int type
)
430 guiSetFilename(guiIntfStruct
.Filename
, name
)
432 guiSetDF(guiIntfStruct
.Filename
, dir
, name
);
434 guiIntfStruct
.StreamType
= type
;
435 free((void **) &guiIntfStruct
.AudioFile
);
436 free((void **) &guiIntfStruct
.Subtitlename
);
439 void mplFullScreen( void )
441 if(!guiIntfStruct
.sh_video
) return;
445 if(!fullscreen
&& IsWindowVisible(mygui
->subwindow
) && !IsIconic(mygui
->subwindow
))
446 GetWindowRect(mygui
->subwindow
, &old_rect
);
451 style
= WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
;
454 style
= WS_VISIBLE
| WS_POPUP
;
456 SetWindowLong(mygui
->subwindow
, GWL_STYLE
, style
);
459 video_out
->control(VOCTRL_FULLSCREEN
, 0);
460 if(sub_window
) ShowWindow(mygui
->subwindow
, SW_SHOW
);
463 static unsigned __stdcall
GuiThread(void* param
)
467 if(!skinName
) skinName
= strdup("Blue");
468 if(!mygui
) mygui
= create_gui(get_path("skins"), skinName
, guiSetEvent
);
469 if(!mygui
) exit_player("Unable to load GUI.");
471 if(autosync
&& autosync
!= gtkAutoSync
)
474 gtkAutoSync
= autosync
;
477 while(GetMessage(&msg
, NULL
, 0, 0))
479 TranslateMessage(&msg
);
480 DispatchMessage(&msg
);
482 fprintf(stderr
, "[GUI] GUI thread terminated.\n");
489 memset(&guiIntfStruct
, 0, sizeof(guiIntfStruct
));
490 /* Create The gui thread */
493 hThread
= _beginthreadex(NULL
, 0, GuiThread
, NULL
, 0, &threadId
);
494 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Creating GUI Thread 0x%04x\n", threadId
);
497 /* Wait until the gui is created */
498 while(!mygui
) Sleep(100);
499 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] GUI thread started.\n");
506 fprintf(stderr
, "[GUI] Closed by main mplayer window\n");
508 PostThreadMessage(threadId
, WM_QUIT
, 0, 0);
509 WaitForSingleObject(hThread
, INFINITE
);
510 CloseHandle(hThread
);
511 mygui
->uninit(mygui
);
515 /* Remove tray icon */
516 Shell_NotifyIcon(NIM_DELETE
, &nid
);
520 /* this function gets called by mplayer to update the gui */
521 int guiGetEvent(int type
, char *arg
)
523 stream_t
*stream
= (stream_t
*) arg
;
524 #ifdef CONFIG_DVDREAD
525 dvd_priv_t
*dvdp
= (dvd_priv_t
*) arg
;
527 if(!mygui
|| !mygui
->skin
) return 0;
529 if(guiIntfStruct
.mpcontext
)
531 audio_out
= mpctx_get_audio_out(guiIntfStruct
.mpcontext
);
532 video_out
= mpctx_get_video_out(guiIntfStruct
.mpcontext
);
533 mixer
= mpctx_get_mixer(guiIntfStruct
.mpcontext
);
534 playtree
= mpctx_get_playtree_iter(guiIntfStruct
.mpcontext
);
539 case guiSetFileFormat
:
540 guiIntfStruct
.FileFormat
= (int) arg
;
542 case guiSetParameters
:
544 guiGetEvent(guiSetDefaults
, NULL
);
545 guiIntfStruct
.DiskChanged
= 0;
546 guiIntfStruct
.FilenameChanged
= 0;
547 guiIntfStruct
.NewPlay
= 0;
548 switch(guiIntfStruct
.StreamType
)
550 case STREAMTYPE_PLAYLIST
:
552 #ifdef CONFIG_DVDREAD
556 dvd_title
= guiIntfStruct
.DVD
.current_title
;
557 dvd_chapter
= guiIntfStruct
.DVD
.current_chapter
;
558 dvd_angle
= guiIntfStruct
.DVD
.current_angle
;
559 sprintf(tmp
,"dvd://%d", guiIntfStruct
.Title
);
560 guiSetFilename(guiIntfStruct
.Filename
, tmp
);
565 if(guiIntfStruct
.Filename
)
566 filename
= strdup(guiIntfStruct
.Filename
);
568 strcpy(guiIntfStruct
.Filename
, filename
);
571 case guiSetAudioOnly
:
573 guiIntfStruct
.AudioOnly
= (int) arg
;
574 if(IsWindowVisible(mygui
->subwindow
))
575 ShowWindow(mygui
->subwindow
, SW_HIDE
);
579 guiIntfStruct
.mpcontext
= (void *) arg
;
582 guiIntfStruct
.demuxer
= (void *) arg
;
586 guiIntfStruct
.sh_video
= arg
;
589 sh_video_t
*sh
= (sh_video_t
*)arg
;
590 codecname
= sh
->codec
->name
;
591 guiIntfStruct
.FPS
= sh
->fps
;
593 /* we have video, show the subwindow */
594 if(!IsWindowVisible(mygui
->subwindow
) || IsIconic(mygui
->subwindow
))
595 ShowWindow(mygui
->subwindow
, SW_SHOWNORMAL
);
604 guiIntfStruct
.MovieWidth
= vo_dwidth
;
605 guiIntfStruct
.MovieHeight
= vo_dheight
;
607 sub_aspect
= (float)guiIntfStruct
.MovieWidth
/guiIntfStruct
.MovieHeight
;
614 guiIntfStruct
.StreamType
= stream
->type
;
617 #ifdef CONFIG_DVDREAD
619 guiGetEvent(guiSetDVD
, (char *) stream
->priv
);
625 #ifdef CONFIG_DVDREAD
628 guiIntfStruct
.DVD
.titles
= dvdp
->vmg_file
->tt_srpt
->nr_of_srpts
;
629 guiIntfStruct
.DVD
.chapters
= dvdp
->vmg_file
->tt_srpt
->title
[dvd_title
].nr_of_ptts
;
630 guiIntfStruct
.DVD
.angles
= dvdp
->vmg_file
->tt_srpt
->title
[dvd_title
].nr_of_angles
;
631 guiIntfStruct
.DVD
.nr_of_audio_channels
= dvdp
->nr_of_channels
;
632 memcpy(guiIntfStruct
.DVD
.audio_streams
, dvdp
->audio_streams
, sizeof(dvdp
->audio_streams
));
633 guiIntfStruct
.DVD
.nr_of_subtitles
= dvdp
->nr_of_subtitles
;
634 memcpy(guiIntfStruct
.DVD
.subtitles
, dvdp
->subtitles
, sizeof(dvdp
->subtitles
));
635 guiIntfStruct
.DVD
.current_title
= dvd_title
+ 1;
636 guiIntfStruct
.DVD
.current_chapter
= dvd_chapter
+ 1;
637 guiIntfStruct
.DVD
.current_angle
= dvd_angle
+ 1;
638 guiIntfStruct
.Track
= dvd_title
+ 1;
643 mygui
->updatedisplay(mygui
, mygui
->mainwindow
);
646 guiIntfStruct
.afilter
= (void *) arg
;
650 guiIntfStruct
.Playing
= (int) arg
;
651 switch (guiIntfStruct
.Playing
)
655 guiIntfStruct
.Playing
= 1;
660 guiIntfStruct
.Playing
= 0;
661 if(movie_aspect
>= 0)
667 guiIntfStruct
.Playing
= 2;
674 mp_msg(MSGT_GPLAYER
,MSGL_V
, "cmd: %d\n", (int) arg
);
675 /* MPlayer asks us to quit */
678 case MP_CMD_GUI_FULLSCREEN
:
683 mygui
->uninit(mygui
);
689 case MP_CMD_GUI_STOP
:
690 guiGetEvent(guiCEvent
, (void *) guiSetStop
);
692 case MP_CMD_GUI_PLAY
:
693 guiGetEvent(guiCEvent
, (void *) guiSetPlay
);
695 case MP_CMD_GUI_SKINBROWSER
:
696 if(fullscreen
) guiSetEvent(evFullScreen
);
697 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_SKINBROWSER
, 0);
699 case MP_CMD_GUI_PLAYLIST
:
700 if(fullscreen
) guiSetEvent(evFullScreen
);
701 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_PLAYLIST
, 0);
703 case MP_CMD_GUI_PREFERENCES
:
704 if(fullscreen
) guiSetEvent(evFullScreen
);
705 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) ID_PREFS
, 0);
707 case MP_CMD_GUI_LOADFILE
:
708 if(fullscreen
) guiSetEvent(evFullScreen
);
709 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) IDFILE_OPEN
, 0);
711 case MP_CMD_GUI_LOADSUBTITLE
:
712 if(fullscreen
) guiSetEvent(evFullScreen
);
713 PostMessage(mygui
->mainwindow
, WM_COMMAND
, (WPARAM
) IDSUBTITLE_OPEN
, 0);
721 if (arg
) guiIntfStruct
.Filename
= (char *) arg
;
729 stream_cache_size
= -1;
734 if(!mygui
->playlist
->tracks
) return 0;
735 filename
= guiIntfStruct
.Filename
= mygui
->playlist
->tracks
[mygui
->playlist
->current
]->filename
;
736 guiIntfStruct
.Track
= mygui
->playlist
->current
+ 1;
737 if(gtkAONorm
) greplace(&af_cfg
.list
, "volnorm", "volnorm");
740 char *name
= malloc(12 + 20 + 1);
741 snprintf(name
, 12 + 20, "extrastereo=%f", gtkAOExtraStereoMul
);
743 greplace(&af_cfg
.list
, "extrastereo", name
);
746 if(gtkCacheOn
) stream_cache_size
= gtkCacheSize
;
747 if(gtkAutoSyncOn
) autosync
= gtkAutoSync
;
754 /* Some audio_out drivers do not support balance e.g. dsound */
755 /* FIXME this algo is not correct */
757 mixer_getvolume(mixer
, &l
, &r
);
758 guiIntfStruct
.Volume
= (r
> l
? r
: l
); /* max(r,l) */
760 guiIntfStruct
.Balance
= ((r
-l
) + 100.0f
) * 0.5f
;
762 guiIntfStruct
.Balance
= 50.0f
;
767 mp_msg(MSGT_GPLAYER
, MSGL_ERR
, "[GUI] GOT UNHANDLED EVENT %i\n", type
);
772 /* This function adds/inserts one file into the gui playlist */
773 int import_file_into_gui(char *pathname
, int insert
)
775 char filename
[MAX_PATH
];
776 char *filepart
= filename
;
778 if (strstr(pathname
, "://"))
780 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Adding special %s\n", pathname
);
781 mygui
->playlist
->add_track(mygui
->playlist
, pathname
, NULL
, NULL
, 0);
784 if (GetFullPathName(pathname
, MAX_PATH
, filename
, &filepart
))
786 if (!(GetFileAttributes(filename
) & FILE_ATTRIBUTE_DIRECTORY
))
788 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Adding filename: %s - fullpath: %s\n", filepart
, filename
);
789 mygui
->playlist
->add_track(mygui
->playlist
, filename
, NULL
, filepart
, 0);
793 mp_msg(MSGT_GPLAYER
, MSGL_V
, "[GUI] Cannot add %s\n", filename
);
799 /* This function imports the initial playtree (based on cmd-line files) into the gui playlist
801 - overwriting gui pl (enqueue=0) */
803 int import_initial_playtree_into_gui(play_tree_t
*my_playtree
, m_config_t
*config
, int enqueue
)
805 play_tree_iter_t
*my_pt_iter
= NULL
;
808 if(!mygui
) guiInit();
810 if((my_pt_iter
= pt_iter_create(&my_playtree
, config
)))
812 while ((filename
= pt_iter_get_next_file(my_pt_iter
)) != NULL
)
814 if (parse_filename(filename
, my_playtree
, config
, 0))
816 else if (import_file_into_gui(filename
, 0)) /* Add it to end of list */
824 mygui
->playlist
->current
= 0;
825 filename
= mygui
->playlist
->tracks
[0]->filename
;
830 /* This function imports and inserts an playtree, that is created "on the fly", for example by
831 parsing some MOV-Reference-File; or by loading an playlist with "File Open"
832 The file which contained the playlist is thereby replaced with it's contents. */
834 int import_playtree_playlist_into_gui(play_tree_t
*my_playtree
, m_config_t
*config
)
836 play_tree_iter_t
*my_pt_iter
= NULL
;
839 if((my_pt_iter
= pt_iter_create(&my_playtree
, config
)))
841 while ((filename
= pt_iter_get_next_file(my_pt_iter
)) != NULL
)
842 if (import_file_into_gui(filename
, 1)) /* insert it into the list and set plCurrent = new item */
844 pt_iter_destroy(&my_pt_iter
);
850 inline void gtkMessageBox(int type
, const char *str
)
852 if (type
& GTK_MB_FATAL
)
853 MessageBox(NULL
, str
, "MPlayer GUI for Windows Error", MB_OK
| MB_ICONERROR
);
855 fprintf(stderr
, "[GUI] MessageBox: %s\n", str
);
859 void guiMessageBox(int level
, char *str
)
864 gtkMessageBox(GTK_MB_FATAL
| GTK_MB_SIMPLE
, str
);
867 gtkMessageBox(GTK_MB_ERROR
| GTK_MB_SIMPLE
, str
);
872 static int update_subwindow(void)
880 WinID
= -1; // so far only directx supports WinID in windows
882 if(IsWindowVisible(mygui
->subwindow
) && guiIntfStruct
.sh_video
&& guiIntfStruct
.Playing
)
884 ShowWindow(mygui
->subwindow
, SW_HIDE
);
887 else if(guiIntfStruct
.AudioOnly
)
889 else ShowWindow(mygui
->subwindow
, SW_SHOW
);
892 /* we've come out of fullscreen at the end of file */
893 if((!IsWindowVisible(mygui
->subwindow
) || IsIconic(mygui
->subwindow
)) && !guiIntfStruct
.AudioOnly
)
894 ShowWindow(mygui
->subwindow
, SW_SHOWNORMAL
);
896 /* get our current window coordinates */
897 GetWindowRect(mygui
->subwindow
, &rd
);
902 /* restore sub window position when coming out of fullscreen */
903 if(x
<= 0) x
= old_rect
.left
;
904 if(y
<= 0) y
= old_rect
.top
;
906 if(!guiIntfStruct
.Playing
)
911 for (i
=0; i
<mygui
->skin
->windowcount
; i
++)
912 if(mygui
->skin
->windows
[i
]->type
== wiSub
)
913 desc
= mygui
->skin
->windows
[i
];
915 rd
.right
= rd
.left
+desc
->base
->bitmap
[0]->width
;
916 rd
.bottom
= rd
.top
+desc
->base
->bitmap
[0]->height
;
917 sub_aspect
= (float)(rd
.right
-rd
.left
)/(rd
.bottom
-rd
.top
);
921 rd
.right
= rd
.left
+guiIntfStruct
.MovieWidth
;
922 rd
.bottom
= rd
.top
+guiIntfStruct
.MovieHeight
;
924 if (movie_aspect
> 0.0) // forced aspect from the cmdline
925 sub_aspect
= movie_aspect
;
929 AdjustWindowRect(&rd
, WS_OVERLAPPEDWINDOW
| WS_SIZEBOX
, 0);
930 SetWindowPos(mygui
->subwindow
, 0, x
, y
, rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, SWP_NOOWNERZORDER
);
932 wp
.hwnd
= mygui
->subwindow
;
935 wp
.cx
= rd
.right
-rd
.left
;
936 wp
.cy
= rd
.bottom
-rd
.top
;
937 wp
.flags
= SWP_NOOWNERZORDER
| SWP_SHOWWINDOW
;
939 /* erase the bitmap image if there's video */
940 if(guiIntfStruct
.Playing
!= 0 && guiIntfStruct
.sh_video
)
941 SendMessage(mygui
->subwindow
, WM_ERASEBKGND
, (WPARAM
)GetDC(mygui
->subwindow
), 0);
943 /* reset the window aspect */
944 SendMessage(mygui
->subwindow
, WM_WINDOWPOSCHANGED
, 0, (LPARAM
)&wp
);
948 void guiEventHandling(void) {}