dacp-player.c 4.01 KB
Newer Older
1
2
3
4
5
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * libdmapsharing
 * Copyright (C) Alexandre Rosenfeld 2010 <alexandre.rosenfeld@gmail.com>
 * 
6
7
8
9
10
11
12
13
14
15
16
17
18
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
 */

#include <libdmapsharing/dacp-player.h>
#include <libdmapsharing/dmap-enums.h>
#include <libdmapsharing/daap-record.h>

static void
dacp_player_init (DACPPlayerInterface *iface)
{
	static gboolean initialized = FALSE;

	if (!initialized) {
		initialized = TRUE;

		g_object_interface_install_property (iface,
			g_param_spec_ulong ("playing-time",
			                    "Playing time",
			                    "Playing time (ms)",
			                    0,
			                    G_MAXULONG,
			                    0,
			                    G_PARAM_READWRITE));

		g_object_interface_install_property (iface,
			g_param_spec_boolean ("shuffle-state",
			                      "Shuffle state",
			                      "Shufle state",
			                      FALSE,
			                      G_PARAM_READWRITE));

		g_object_interface_install_property (iface,
			g_param_spec_enum ("repeat-state",
			                   "Repeat state",
			                   "Repeat state",
			                   TYPE_DACP_REPEAT_STATE,
			                   REPEAT_NONE,
			                   G_PARAM_READWRITE));

		g_object_interface_install_property (iface,
			g_param_spec_enum ("play-state",
			                   "Play state",
			                   "Play state",
			                   TYPE_DACP_PLAY_STATE,
			                   PLAY_STOPPED,
			                   G_PARAM_READWRITE));
		
		g_object_interface_install_property (iface,
			g_param_spec_ulong ("volume",
			                    "Volume",
			                    "Volume",
			                    0,
			                    100,
			                    0,
			                    G_PARAM_READWRITE));
	}
}

static void
dacp_player_finalize (DACPPlayerInterface *iface)
{
}

GType
dacp_player_get_type (void)
{
	static GType object_type = 0;
	if (!object_type) {
		static const GTypeInfo object_info = {
			sizeof(DACPPlayerInterface),
			(GBaseInitFunc) dacp_player_init,
			(GBaseFinalizeFunc) dacp_player_finalize
		};
		object_type = g_type_register_static(G_TYPE_INTERFACE,
		                                     "DACPPlayer",
		                                     &object_info, 0);
	}
	return object_type;
}

DAAPRecord *
dacp_player_now_playing_record (DACPPlayer *player)
{
	return DACP_PLAYER_GET_INTERFACE (player)->now_playing_record (player);
}

gchar *
dacp_player_now_playing_artwork (DACPPlayer *player, guint width, guint height)
{
	return DACP_PLAYER_GET_INTERFACE (player)->now_playing_artwork (player, width, height);
}

void 
dacp_player_play_pause (DACPPlayer *player)
{
	DACP_PLAYER_GET_INTERFACE (player)->play_pause (player);
}


void 
dacp_player_pause (DACPPlayer *player)
{
	DACP_PLAYER_GET_INTERFACE (player)->pause (player);
}

void 
dacp_player_next_item (DACPPlayer *player)
{
	DACP_PLAYER_GET_INTERFACE (player)->next_item (player);
}

void 
dacp_player_prev_item (DACPPlayer *player)
{
	DACP_PLAYER_GET_INTERFACE (player)->prev_item (player);
}

void 
dacp_player_cue_clear (DACPPlayer *player)
{
	DACP_PLAYER_GET_INTERFACE (player)->cue_clear (player);
}

void 
dacp_player_cue_play (DACPPlayer *player, GList *records, guint index)
{
	DACP_PLAYER_GET_INTERFACE (player)->cue_play (player, records, index);
}