Skip to content

Commit

Permalink
Integrate shuffle status
Browse files Browse the repository at this point in the history
Issue: tiliado/nuvolaplayer#20

Signed-off-by: Jiří Janoušek <[email protected]>
  • Loading branch information
jiri-janousek committed Sep 21, 2018
1 parent 5479936 commit 4e0a455
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions integrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
player.setCanRepeat(repeat !== null)
player.setRepeatState(repeat)

var shuffle = this._getShuffle()
player.setCanShuffle(shuffle !== null)
player.setShuffleState(shuffle)

// Schedule the next update
setTimeout(this.update.bind(this), 500)
}
Expand Down Expand Up @@ -216,6 +220,15 @@
}
}

WebApp._getShuffleButton = function () {
return document.getElementById('shuffle')
}

WebApp._getShuffle = function () {
var button = this._getShuffleButton()
return button ? button.classList.contains('active') : null
}

// Handler of playback actions
WebApp._onActionActivated = function (emitter, name, param) {
switch (name) {
Expand Down Expand Up @@ -250,6 +263,9 @@
case PlayerAction.REPEAT:
this._setRepeat(param)
break
case PlayerAction.SHUFFLE:
Nuvola.clickOnElement(this._getShuffleButton())
break
}
}

Expand Down

0 comments on commit 4e0a455

Please sign in to comment.