2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
23 #include <stdlib.h> /* exit() */
31 static GMainLoop *loop;
34 error_eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop)
36 g_main_loop_quit (main_loop);
40 main (gint argc, gchar * argv[])
43 GstStateChangeReturn res;
46 gst_init (&argc, &argv);
48 player = gst_element_factory_make ("playbin", "player");
52 g_print ("usage: %s <uri>\n", argv[0]);
56 loop = g_main_loop_new (NULL, TRUE);
57 bus = gst_pipeline_get_bus (GST_PIPELINE (player));
58 gst_bus_add_signal_watch (bus);
60 g_signal_connect (bus, "message::eos", G_CALLBACK (error_eos_cb), loop);
61 g_signal_connect (bus, "message::error", G_CALLBACK (error_eos_cb), loop);
63 g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
65 g_print ("play...\n");
66 res = gst_element_set_state (player, GST_STATE_PLAYING);
67 if (res == GST_STATE_CHANGE_FAILURE) {
68 g_print ("could not play\n");
72 g_print ("sleep 2...\n");
73 g_usleep (2 * G_USEC_PER_SEC);
75 g_print ("pause...\n");
76 res = gst_element_set_state (player, GST_STATE_PAUSED);
77 if (res == GST_STATE_CHANGE_FAILURE) {
78 g_print ("could not pause\n");
82 g_print ("sleep 2...\n");
83 g_usleep (2 * G_USEC_PER_SEC);
85 g_print ("play...\n");
86 res = gst_element_set_state (player, GST_STATE_PLAYING);
87 if (res == GST_STATE_CHANGE_FAILURE) {
88 g_print ("could not play\n");
92 g_print ("sleep 2...\n");
93 g_usleep (2 * G_USEC_PER_SEC);
95 g_print ("ready...\n");
96 res = gst_element_set_state (player, GST_STATE_READY);
97 if (res != GST_STATE_CHANGE_SUCCESS) {
98 g_print ("could not play\n");
102 g_print ("sleep 2...\n");
103 g_usleep (2 * G_USEC_PER_SEC);
105 g_print ("play...\n");
106 res = gst_element_set_state (player, GST_STATE_PLAYING);
107 if (res == GST_STATE_CHANGE_FAILURE) {
108 g_print ("could not play\n");
112 g_main_loop_run (loop);