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() */
27 static GMainLoop *loop;
30 error_eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop)
32 g_main_loop_quit (main_loop);
36 main (gint argc, gchar * argv[])
39 GstStateChangeReturn res;
42 gst_init (&argc, &argv);
44 player = gst_element_factory_make ("playbin", "player");
48 g_print ("usage: %s <uri>\n", argv[0]);
52 loop = g_main_loop_new (NULL, TRUE);
53 bus = gst_pipeline_get_bus (GST_PIPELINE (player));
54 gst_bus_add_signal_watch (bus);
56 g_signal_connect (bus, "message::eos", G_CALLBACK (error_eos_cb), loop);
57 g_signal_connect (bus, "message::error", G_CALLBACK (error_eos_cb), loop);
59 g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
61 g_print ("play...\n");
62 res = gst_element_set_state (player, GST_STATE_PLAYING);
63 if (res == GST_STATE_CHANGE_FAILURE) {
64 g_print ("could not play\n");
68 g_print ("sleep 2...\n");
69 g_usleep (2 * G_USEC_PER_SEC);
71 g_print ("pause...\n");
72 res = gst_element_set_state (player, GST_STATE_PAUSED);
73 if (res == GST_STATE_CHANGE_FAILURE) {
74 g_print ("could not pause\n");
78 g_print ("sleep 2...\n");
79 g_usleep (2 * G_USEC_PER_SEC);
81 g_print ("play...\n");
82 res = gst_element_set_state (player, GST_STATE_PLAYING);
83 if (res == GST_STATE_CHANGE_FAILURE) {
84 g_print ("could not play\n");
88 g_print ("sleep 2...\n");
89 g_usleep (2 * G_USEC_PER_SEC);
91 g_print ("ready...\n");
92 res = gst_element_set_state (player, GST_STATE_READY);
93 if (res != GST_STATE_CHANGE_SUCCESS) {
94 g_print ("could not play\n");
98 g_print ("sleep 2...\n");
99 g_usleep (2 * G_USEC_PER_SEC);
101 g_print ("play...\n");
102 res = gst_element_set_state (player, GST_STATE_PLAYING);
103 if (res == GST_STATE_CHANGE_FAILURE) {
104 g_print ("could not play\n");
108 g_main_loop_run (loop);