2 * Copyright (C) 2008 Rov Juvano <rovjuvano@users.sourceforge.net>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "demo-player.h"
25 extern GOptionGroup
* gtk_get_option_group (gboolean
);
26 extern GOptionGroup
* gst_init_get_option_group (void);
29 handle_error_message (DemoPlayer
*player
,
33 const gchar
*format
= (const gchar
*)data
;
34 g_print (format
, msg
);
38 handle_quit (gpointer source
,
41 g_main_loop_quit ((GMainLoop
*)data
);
46 main (int argc
, char *argv
[])
49 gchar
*filter_name
= "identity";
51 const GOptionEntry entries
[] = {
52 { "filter", '\0', 0, G_OPTION_ARG_STRING
, &filter_name
,
54 { G_OPTION_REMAINING
, 0, 0, G_OPTION_ARG_FILENAME_ARRAY
, &uris
,
55 "Special option that collects any remaining arguments for us" },
59 if (!g_thread_supported ())
62 GOptionContext
*ctx
= g_option_context_new ("uri ...");
63 g_option_context_add_group (ctx
, gst_init_get_option_group ());
64 g_option_context_add_group (ctx
, gtk_get_option_group (FALSE
));
65 g_option_context_add_main_entries (ctx
, entries
, NULL
);
67 if (!g_option_context_parse (ctx
, &argc
, &argv
, &err
)) {
68 g_print ("Error initializing: %s\n", err
->message
);
72 g_option_context_free (ctx
);
74 if (uris
== NULL
|| *uris
== NULL
) {
75 g_print ("Please specify a URI to play\n\n");
79 DemoGui
*gui
= g_object_new (DEMO_TYPE_GUI
, NULL
);
80 DemoPlayer
*player
= g_object_new (DEMO_TYPE_PLAYER
, "filter", filter_name
, NULL
);
81 g_signal_connect (player
, "error", G_CALLBACK (handle_error_message
), "PLAYER ERROR: %s\n");
82 g_signal_connect (gui
, "error", G_CALLBACK (handle_error_message
), "GUI ERROR: %s\n");
83 demo_gui_set_player (gui
, player
);
85 GMainLoop
*loop
= g_main_loop_new (NULL
, FALSE
);
86 g_signal_connect (gui
, "quiting", G_CALLBACK (handle_quit
), loop
);
88 int i
, num
= g_strv_length (uris
);
89 GList
*uri_list
= NULL
;
90 for (i
=0; i
<num
; i
++) {
91 uri_list
= g_list_append (uri_list
, uris
[i
]);
95 demo_gui_set_playlist (gui
, uri_list
);
96 g_main_loop_run (loop
);