2
* * Copyright (C) 2009 Ali <aliov@xfce.org>
4
* Licensed under the GNU General Public License Version 2
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
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.
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
25
#include "parole-provider-player.h"
26
#include "parole-marshal.h"
27
#include "parole-enum-types.h"
29
static void parole_provider_player_base_init (gpointer klass);
30
static void parole_provider_player_class_init (gpointer klass);
33
parole_provider_player_get_type (void)
35
static GType type = G_TYPE_INVALID;
37
if (G_UNLIKELY (type == G_TYPE_INVALID))
39
static const GTypeInfo info =
41
sizeof (ParoleProviderPlayerIface),
42
(GBaseInitFunc) parole_provider_player_base_init,
44
(GClassInitFunc) parole_provider_player_class_init,
53
type = g_type_register_static (G_TYPE_INTERFACE, "ParoleProviderPlayerIface", &info, 0);
55
g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
61
static void parole_provider_player_base_init (gpointer klass)
63
static gboolean initialized = FALSE;
65
if (G_UNLIKELY (!initialized))
68
* ParoleProviderPlayerIface::state-changed:
69
* @player: the object which received the signal.
70
* @stream: a #ParoleStream.
71
* @state: the new state.
73
* Issued when the Parole state changed.
77
g_signal_new ("state-changed",
78
G_TYPE_FROM_INTERFACE (klass),
80
G_STRUCT_OFFSET (ParoleProviderPlayerIface, state_changed),
82
parole_marshal_VOID__OBJECT_ENUM,
84
PAROLE_TYPE_STREAM, PAROLE_ENUM_TYPE_STATE);
87
* ParoleProviderPlayerIface::tag-message:
88
* @player: the object which received the signal.
89
* @stream: a #ParoleStream.
91
* Indicated that the stream tags were found and ready to be read.
95
g_signal_new ("tag-message",
96
G_TYPE_FROM_INTERFACE (klass),
98
G_STRUCT_OFFSET (ParoleProviderPlayerIface, tag_message),
100
g_cclosure_marshal_VOID__OBJECT,
101
G_TYPE_NONE, 1, PAROLE_TYPE_STREAM);
107
static void parole_provider_player_class_init (gpointer klass)
112
* parole_provider_player_get_main_window:
113
* @player: a #ParoleProviderPlayer
115
* Ask the Player to get the Parole main window.
117
* Returns: #GtkWidget window.
121
GtkWidget *parole_provider_player_get_main_window (ParoleProviderPlayer *player)
123
GtkWidget *window = NULL;
125
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), NULL);
127
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_main_window )
129
window = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_main_window) (player);
135
* parole_provider_player_pack:
136
* @player: a #ParoleProviderPlayer
137
* @widget: a #GtkWidget.
139
* @container: a #ParolePluginContainer.
141
* Ask the player to pack a widget in the playlist notebook if PAROLE_PLUGIN_CONTAINER_PLAYLIST
142
* is specified or in the main window notebook if PAROLE_PLUGIN_CONTAINER_MAIN_VIEW is specified.
144
* This function can be called once, the Player is responsible on removing the widget in
145
* case the plugin was unloaded.
150
void parole_provider_player_pack (ParoleProviderPlayer *player, GtkWidget *widget,
151
const gchar *title, ParolePluginContainer container)
153
g_return_if_fail (PAROLE_IS_PROVIDER_PLAYER (player));
155
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pack )
157
(*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pack) (player, widget, title, container);
162
* parole_provider_player_get_state:
163
* @player: a #ParoleProviderPlayer
165
* Get the current state of the player.
167
* Returns: a #ParoleState.
172
ParoleState parole_provider_player_get_state (ParoleProviderPlayer *player)
174
ParoleState state = PAROLE_STATE_STOPPED;
176
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), PAROLE_STATE_STOPPED);
178
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_state )
180
state = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_state) (player);
187
* parole_provider_player_get_stream:
188
* @player: a #ParoleProviderPlayer
190
* Get the #ParoleStream object.
192
* Returns: the #ParoleStream object.
196
const ParoleStream *parole_provider_player_get_stream (ParoleProviderPlayer *player)
198
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), NULL);
200
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_stream )
202
return (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->get_stream) (player);
209
* parole_provider_player_play_uri:
210
* @player: a #ParoleProviderPlayer
213
* Issue a play command on the backend for the given uri, note this function
214
* can be called only of the Parole current state is PAROLE_STATE_STOPPED.
216
* Returning TRUE doesn't mean that the funtion succeeded to change the state of the player,
217
* the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
219
* Returns: TRUE if the command is processed, FALSE otherwise.
223
gboolean parole_provider_player_play_uri (ParoleProviderPlayer *player, const gchar *uri)
225
gboolean ret = FALSE;
227
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
229
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->play_uri )
231
ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->play_uri) (player, uri);
238
* parole_provider_player_pause:
239
* @player: a #ParoleProviderPlayer
241
* Issue a pause command to the backend, this function can be called when the state of the player
242
* is PAROLE_STATE_PLAYING.
244
* Returning TRUE doesn't mean that the funtion succeeded to change the state of the player,
245
* the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
247
* Returns: TRUE if the command is processed, FALSE otherwise.
252
gboolean parole_provider_player_pause (ParoleProviderPlayer *player)
254
gboolean ret = FALSE;
256
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
258
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pause )
260
ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->pause) (player);
268
* parole_provider_player_resume:
269
* @player: a #ParoleProviderPlayer
272
* Issue a resume command to the player, this function can be called when
273
* the current state of the player is PAROLE_STATE_PAUSED.
275
* Returning TRUE doesn't mean that the funtion succeeded to change the state of the player,
276
* the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
278
* Returns: TRUE if the command is processed, FALSE otherwise.
283
gboolean parole_provider_player_resume (ParoleProviderPlayer *player)
285
gboolean ret = FALSE;
287
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
289
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->resume )
291
ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->resume) (player);
299
* parole_provider_player_stop:
300
* @player: a #ParoleProviderPlayer
302
* Issue a stop command to the player.
304
* Returning TRUE doesn't mean that the funtion succeeded to change the state of the player,
305
* the state change is indicated asynchronously by #ParoleProviderPlayerIface::state-changed signal.
307
* Returns: TRUE if the command is processed, FALSE otherwise.
311
gboolean parole_provider_player_stop (ParoleProviderPlayer *player)
313
gboolean ret = FALSE;
315
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
317
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->stop )
319
ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->stop) (player);
327
* parole_provider_player_seek:
328
* @player: a #ParoleProviderPlayer
329
* @pos: position to seek.
332
* Issue a seek command.
334
* Returns: TRUE if the seek command succeeded, FALSE otherwise.
339
gboolean parole_provider_player_seek (ParoleProviderPlayer *player, gdouble pos)
341
gboolean ret = FALSE;
343
g_return_val_if_fail (PAROLE_IS_PROVIDER_PLAYER (player), FALSE);
345
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->seek )
347
ret = (*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->seek) (player, pos);
355
* parole_provider_player_open_media_chooser:
356
* @player: a #ParoleProviderPlayer
358
* Ask Parole to open its media chooser dialog.
362
void parole_provider_player_open_media_chooser (ParoleProviderPlayer *player)
364
g_return_if_fail (PAROLE_IS_PROVIDER_PLAYER (player));
366
if ( PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->open_media_chooser )
368
(*PAROLE_PROVIDER_PLAYER_GET_INTERFACE (player)->open_media_chooser) (player);