1 /* Copyright (C) Alexandre Rosenfeld 2010 <alexandre.rosenfeld@gmail.com>
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 #include <libdmapsharing/dacp-player.h>
19 #include <libdmapsharing/dmap-enums.h>
20 #include <libdmapsharing/daap-record.h>
21
22 static void
dacp_player_init(DACPPlayerIface * iface)23 dacp_player_init (DACPPlayerIface * iface)
24 {
25 static gboolean initialized = FALSE;
26
27 if (!initialized) {
28 initialized = TRUE;
29
30 g_object_interface_install_property (iface,
31 g_param_spec_ulong
32 ("playing-time",
33 "Playing time",
34 "Playing time (ms)", 0,
35 G_MAXULONG, 0,
36 G_PARAM_READWRITE));
37
38 g_object_interface_install_property (iface,
39 g_param_spec_boolean
40 ("shuffle-state",
41 "Shuffle state",
42 "Shufle state", FALSE,
43 G_PARAM_READWRITE));
44
45 g_object_interface_install_property (iface,
46 g_param_spec_enum
47 ("repeat-state",
48 "Repeat state",
49 "Repeat state",
50 DMAP_TYPE_DACP_REPEAT_STATE,
51 DACP_REPEAT_NONE,
52 G_PARAM_READWRITE));
53
54 g_object_interface_install_property (iface,
55 g_param_spec_enum
56 ("play-state",
57 "Play state",
58 "Play state",
59 DMAP_TYPE_DACP_PLAY_STATE,
60 DACP_PLAY_STOPPED,
61 G_PARAM_READWRITE));
62
63 g_object_interface_install_property (iface,
64 g_param_spec_ulong
65 ("volume", "Volume",
66 "Volume", 0, 100, 0,
67 G_PARAM_READWRITE));
68 }
69 }
70
71 static void
dacp_player_finalize(G_GNUC_UNUSED DACPPlayerIface * iface)72 dacp_player_finalize (G_GNUC_UNUSED DACPPlayerIface * iface)
73 {
74 }
75
76 GType
dacp_player_get_type(void)77 dacp_player_get_type (void)
78 {
79 static GType object_type = 0;
80
81 if (!object_type) {
82 static const GTypeInfo object_info = {
83 class_size: sizeof (DACPPlayerIface),
84 base_init: (GBaseInitFunc) dacp_player_init,
85 base_finalize: (GBaseFinalizeFunc) dacp_player_finalize
86 };
87 object_type = g_type_register_static (G_TYPE_INTERFACE,
88 "DACPPlayer",
89 &object_info, 0);
90 g_type_interface_add_prerequisite (object_type,
91 G_TYPE_OBJECT);
92 }
93 return object_type;
94 }
95
96 DAAPRecord *
dacp_player_now_playing_record(DACPPlayer * player)97 dacp_player_now_playing_record (DACPPlayer * player)
98 {
99 return DACP_PLAYER_GET_INTERFACE (player)->
100 now_playing_record (player);
101 }
102
103 guchar *
dacp_player_now_playing_artwork(DACPPlayer * player,guint width,guint height)104 dacp_player_now_playing_artwork (DACPPlayer * player, guint width,
105 guint height)
106 {
107 return DACP_PLAYER_GET_INTERFACE (player)->
108 now_playing_artwork (player, width, height);
109 }
110
111 void
dacp_player_play_pause(DACPPlayer * player)112 dacp_player_play_pause (DACPPlayer * player)
113 {
114 DACP_PLAYER_GET_INTERFACE (player)->play_pause (player);
115 }
116
117 void
dacp_player_pause(DACPPlayer * player)118 dacp_player_pause (DACPPlayer * player)
119 {
120 DACP_PLAYER_GET_INTERFACE (player)->pause (player);
121 }
122
123 void
dacp_player_next_item(DACPPlayer * player)124 dacp_player_next_item (DACPPlayer * player)
125 {
126 DACP_PLAYER_GET_INTERFACE (player)->next_item (player);
127 }
128
129 void
dacp_player_prev_item(DACPPlayer * player)130 dacp_player_prev_item (DACPPlayer * player)
131 {
132 DACP_PLAYER_GET_INTERFACE (player)->prev_item (player);
133 }
134
135 void
dacp_player_cue_clear(DACPPlayer * player)136 dacp_player_cue_clear (DACPPlayer * player)
137 {
138 DACP_PLAYER_GET_INTERFACE (player)->cue_clear (player);
139 }
140
141 void
dacp_player_cue_play(DACPPlayer * player,GList * records,guint index)142 dacp_player_cue_play (DACPPlayer * player, GList * records, guint index)
143 {
144 DACP_PLAYER_GET_INTERFACE (player)->cue_play (player, records, index);
145 }
146