Skip to content

Commit

Permalink
Use event's data to determine if the player is playing.
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
metoule committed Aug 30, 2022
1 parent df1f908 commit a110a4b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripts/deezer/player_observer.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}

// get data from JS object dzPlayer
function updateDeezerControlData() {
function updateDeezerControlData(event, data) {
"use strict";
var DeezerControlData = document.getElementById('DeezerControlData'),
isPlaying = dzPlayer.isPlaying(),
Expand All @@ -144,6 +144,11 @@
break;
}

// the data parameter depends on the event type
if (event && event.namespace === 'PLAYER.pause') {
isPlaying = !data;
}

DeezerControlData.setAttribute('dz_is_active', true);
DeezerControlData.setAttribute('dz_playing', isPlaying);
DeezerControlData.setAttribute('dz_artist', metadata.artist);
Expand Down

0 comments on commit a110a4b

Please sign in to comment.