193
/*static gboolean _can_control (void)
195
return cairo_dock_dbus_get_property_as_int (myData.dbus_proxy_player, "org.mpris.MediaPlayer2.Player", "CanControl");
198
static double cd_mpris2_get_volume (void)
200
return cairo_dock_dbus_get_property_as_double (myData.dbus_proxy_player, "org.mpris.MediaPlayer2.Player", "Volume");
193
203
static gboolean _extract_metadata (GHashTable *pMetadata)
195
205
gboolean bTrackHasChanged = FALSE;
276
286
cCoverPath = g_value_get_string(v);
278
cd_musicplayer_get_cover_path (cCoverPath, TRUE); // did it at the end (we have to know the artist and the album if (cCoverPath == NULL))
288
cd_musicplayer_set_cover_path (cCoverPath); // do it at the end (we have to know the artist and the album if (cCoverPath == NULL))
280
290
/// we miss iTrackListIndex and tracklist-length ...
366
376
if (strcmp (cInterface, "org.mpris.MediaPlayer2.Player") == 0)
368
378
v = g_hash_table_lookup (pChangedProps, "PlaybackStatus");
369
if (v != NULL && G_VALUE_HOLDS_STRING (v))
379
if (v != NULL && G_VALUE_HOLDS_STRING (v)) // status has changed
371
381
const gchar *cStatus = g_value_get_string (v); // "Playing", "Paused" or "Stopped"
372
382
myData.iPlayingStatus = _extract_status (cStatus);
375
385
if (myData.iPlayingStatus == PLAYER_PLAYING) // le handler est stoppe lorsque le lecteur ne joue rien.
376
386
cd_musicplayer_relaunch_handler ();
378
if (! myData.cover_exist && (myData.cPlayingUri != NULL || myData.cTitle != NULL))
380
cd_musicplayer_set_surface (myData.iPlayingStatus);
381
cd_debug ("cover (%d), cPlayingUri (%s), cTitle (%s)", myData.cover_exist, myData.cPlayingUri, myData.cTitle);
385
CD_APPLET_REDRAW_MY_ICON;
388
cd_musicplayer_update_icon ();
389
391
v = g_hash_table_lookup (pChangedProps, "Metadata");
392
394
GHashTable *pMetadata = g_value_get_boxed (v);
393
395
gboolean bTrackHasChanged = _extract_metadata (pMetadata);
395
if (bTrackHasChanged)
397
if (bTrackHasChanged) // new song (song changed or started playing)
397
399
myData.iPlayingStatus = PLAYER_PLAYING; // pour les lecteurs bugues comme Exaile qui envoit un statut "stop" au changement de musique sans envoyer de status "play" par la suite. On considere donc que si le lecteur joue une nouvelle musique, c'est qu'il est en "play".
398
cd_musicplayer_update_icon (TRUE);
400
cd_musicplayer_update_icon ();
400
else if (myData.iPlayingStatus == PLAYER_STOPPED)
401
cd_musicplayer_update_icon (TRUE); // Force the update of the icon if the player is now stopped.
404
else /*if (strcmp (cInterface, "org.mpris.MediaPlayer2.TrackList") == 0)
404
/*else if (strcmp (cInterface, "org.mpris.MediaPlayer2.TrackList") == 0)
408
409
cd_debug ("Another interface: %s", cInterface);
466
468
case PLAYER_SHUFFLE :
467
469
bToggleValue = cd_mpris2_is_shuffle ();
468
470
cd_debug ("SetRandom <- %d\n", !bToggleValue);
469
dbus_g_proxy_call_no_reply (myData.dbus_proxy_player, "Set",
471
G_TYPE_STRING, "org.mpris.MediaPlayer2.Player",
472
G_TYPE_STRING, "Shuffle",
473
G_TYPE_BOOLEAN, !bToggleValue,
471
g_value_init (&s_pValue, G_TYPE_BOOLEAN);
472
g_value_set_boolean (&s_pValue, !bToggleValue);
473
cairo_dock_dbus_set_property (myData.dbus_proxy_player, "org.mpris.MediaPlayer2.Player", "Shuffle", &s_pValue);
474
g_value_unset (&s_pValue);
477
477
case PLAYER_REPEAT :
478
478
bToggleValue = cd_mpris2_is_loop ();
479
479
cd_debug ("SetLoop <- %d\n", !bToggleValue);
480
dbus_g_proxy_call_no_reply (myData.dbus_proxy_player, "Set",
482
G_TYPE_STRING, "org.mpris.MediaPlayer2.Player",
483
G_TYPE_STRING, "LoopStatus",
484
G_TYPE_STRING, (bToggleValue ? "None" : "Playlist"),
480
g_value_init (&s_pValue, G_TYPE_STRING);
481
g_value_set_static_string (&s_pValue, bToggleValue ? "None" : "Playlist");
482
cairo_dock_dbus_set_property (myData.dbus_proxy_player, "org.mpris.MediaPlayer2.Player", "LoopStatus", &s_pValue);
483
g_value_unset (&s_pValue);
488
486
case PLAYER_ENQUEUE :
515
double fVolume = cd_mpris2_get_volume (); // [0, 1]
516
if (song && strcmp (song, "up") == 0)
520
cd_debug ("volume <- %f\n", fVolume);
521
g_value_init (&s_pValue, G_TYPE_DOUBLE);
522
g_value_set_double (&s_pValue, fVolume);
523
cairo_dock_dbus_set_property (myData.dbus_proxy_player, "org.mpris.MediaPlayer2.Player", "Volume", &s_pValue);
524
g_value_unset (&s_pValue);
633
645
pHandler->appclass = NULL; // will be filled later.
634
646
pHandler->launch = NULL; // will be filled later.
635
pHandler->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT | PLAYER_STOP | PLAYER_SHUFFLE | PLAYER_REPEAT | PLAYER_ENQUEUE;
647
pHandler->iPlayerControls = PLAYER_PREVIOUS | PLAYER_PLAY_PAUSE | PLAYER_NEXT | PLAYER_STOP | PLAYER_SHUFFLE | PLAYER_REPEAT | PLAYER_ENQUEUE | PLAYER_VOLUME;
636
648
cd_musicplayer_register_my_handler (pHandler);