Project

General

Profile

handlers_playback.c

Jim Turner, November 21, 2015 18:54

 
1
/*
2
 * handlers_playback.c
3
 * Copyright 2005-2013 George Averill, William Pitcock, Matti Hämäläinen, and
4
 *                     John Lindgren
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * 1. Redistributions of source code must retain the above copyright notice,
10
 *    this list of conditions, and the following disclaimer.
11
 *
12
 * 2. Redistributions in binary form must reproduce the above copyright notice,
13
 *    this list of conditions, and the following disclaimer in the documentation
14
 *    provided with the distribution.
15
 *
16
 * This software is provided "as is" and without any warranty, express or
17
 * implied. In no event shall the authors be liable for any damages arising from
18
 * the use of this software.
19
 */
20

    
21
#include <stdlib.h>
22
#include "audtool.h"
23

    
24
void playback_play (int argc, char * * argv)
25
{
26
    obj_audacious_call_play_sync (dbus_proxy, NULL, NULL);
27
}
28

    
29
void playback_pause (int argc, char * * argv)
30
{
31
    obj_audacious_call_pause_sync (dbus_proxy, NULL, NULL);
32
}
33

    
34
void playback_playpause (int argc, char * * argv)
35
{
36
    obj_audacious_call_play_pause_sync (dbus_proxy, NULL, NULL);
37
}
38

    
39
void playback_stop (int argc, char * * argv)
40
{
41
    obj_audacious_call_stop_sync (dbus_proxy, NULL, NULL);
42
}
43

    
44
void playback_playing (int argc, char * * argv)
45
{
46
    gboolean playing = FALSE;
47
    obj_audacious_call_playing_sync (dbus_proxy, & playing, NULL, NULL);
48

    
49
    exit (! playing);
50
}
51

    
52
void playback_record (int argc, char * * argv)
53
{
54
    obj_audacious_call_playback_record (dbus_proxy, NULL, NULL);
55
}
56

    
57
void playback_paused (int argc, char * * argv)
58
{
59
    gboolean paused = FALSE;
60
    obj_audacious_call_paused_sync (dbus_proxy, & paused, NULL, NULL);
61

    
62
    exit (! paused);
63
}
64

    
65
void playback_stopped (int argc, char * * argv)
66
{
67
    gboolean stopped = FALSE;
68
    obj_audacious_call_stopped_sync (dbus_proxy, & stopped, NULL, NULL);
69

    
70
    exit (! stopped);
71
}
72

    
73
void playback_status (int argc, char * * argv)
74
{
75
    char * status = NULL;
76
    obj_audacious_call_status_sync (dbus_proxy, & status, NULL, NULL);
77

    
78
    if (! status)
79
        exit (1);
80

    
81
    audtool_report ("%s", status);
82
    g_free (status);
83
}
84

    
85
void playback_seek (int argc, char * * argv)
86
{
87
    if (argc < 2)
88
    {
89
        audtool_whine_args (argv[0], "<position>");
90
        exit (1);
91
    }
92

    
93
    obj_audacious_call_seek_sync (dbus_proxy, MAX (0, atof (argv[1]) * 1000), NULL, NULL);
94
}
95

    
96
void playback_seek_relative (int argc, char * * argv)
97
{
98
    if (argc < 2)
99
    {
100
        audtool_whine_args (argv[0], "<position>");
101
        exit (1);
102
    }
103

    
104
    unsigned oldtime = 0;
105
    obj_audacious_call_time_sync (dbus_proxy, & oldtime, NULL, NULL);
106
    obj_audacious_call_seek_sync (dbus_proxy, MAX (0, oldtime + atof (argv[1]) * 1000), NULL, NULL);
107
}