Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
GPM: improve playback status detection (#129)
Browse files Browse the repository at this point in the history
Improve the detection of the current playback status by looking for the
disabled vs enabled state of the play-pause button, and for the
"playing" class name.

Google Play Music seems to have migrated away from "paper-icon-button-0"
preventing the previous method from working.
  • Loading branch information
terinjokes authored and ColinDuquesnoy committed Oct 10, 2017
1 parent 9718ed8 commit edaf8d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Contributors
- [ConorIA](https://github.com/ConorIA)
- [ZeroDot1](http://basic1.moy.su/)
- [Lukas Kolletzki](https://github.com/kolletzki)
- [Mahmoud Hossam](https://github.com/mahmoudhossam)
- [Mahmoud Hossam](https://github.com/mahmoudhossam)
- [Terin Stock](https://github.com/terinjokes)
11 changes: 7 additions & 4 deletions plugins/googleplaymusic/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ function getButtons() {
// Much of this was adapted from: https://github.com/tiliado/nuvola-app-google-play-music
//-----------------------------------------------------------------------------
function update() {
var controlClassName = document.querySelector("#player div.material-player-middle").children[3].className;
var playbackStatus = mellowplayer.PlaybackStatus.STOPPED;
if (controlClassName === "x-scope paper-icon-button-0 playing")
var pp = getButtons().playpause;
var playbackStatus;

if (pp.disabled)
playbackStatus = mellowplayer.PlaybackStatus.STOPPED;
else if (pp.className.indexOf("playing") != -1)
playbackStatus = mellowplayer.PlaybackStatus.PLAYING;
else if (controlClassName === "x-scope paper-icon-button-0")
else
playbackStatus = mellowplayer.PlaybackStatus.PAUSED;

var elm;
Expand Down

0 comments on commit edaf8d4

Please sign in to comment.