~ubuntu-branches/ubuntu/vivid/alarm-clock-applet/vivid

« back to all changes in this revision

Viewing changes to src/tests/test_player.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-05-30 23:24:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090530232427-88on1j2ily4ajxdz
Tags: upstream-0.2.6
ImportĀ upstreamĀ versionĀ 0.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * test_player.c -- Test utility for the MediaPlayer system.
 
3
 * 
 
4
 * Copyright (C) 2007-2008 Johannes H. Jensen <joh@pseudoberries.com>
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 * 
 
20
 * Authors:
 
21
 *              Johannes H. Jensen <joh@pseudoberries.com>
 
22
 */
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include "player.h"
 
27
 
 
28
void state_changed (MediaPlayer *player, MediaPlayerState state, gchar *data)
 
29
{
 
30
        g_debug ("State changed to %s [%d], data is '%s'", 
 
31
                                (state == MEDIA_PLAYER_PLAYING) ? "PLAYING" : "STOPPED",
 
32
                                state, data);
 
33
}
 
34
 
 
35
void error_handler (MediaPlayer *player, GError *error, gchar *data)
 
36
{
 
37
        g_debug ("Error occured: %s, data is '%s'", error->message, data);
 
38
}
 
39
 
 
40
int main (int argc, char **argv)
 
41
{
 
42
        if (argc < 2) {
 
43
                g_print ("Usage: %s <uri>\n", argv[0]);
 
44
                return 1;
 
45
        }
 
46
        
 
47
        MediaPlayer *player;
 
48
        GMainLoop *loop;
 
49
        
 
50
        player = media_player_new(argv[1], FALSE, 
 
51
                                                          state_changed, "test data", 
 
52
                                                          error_handler, "test error");
 
53
        
 
54
        media_player_start (player);
 
55
        
 
56
        loop = g_main_loop_new (g_main_context_default(), TRUE);
 
57
        
 
58
        g_main_loop_run (loop);
 
59
        
 
60
        media_player_free(player);
 
61
        
 
62
        return 0;
 
63
}