gmusic-utils / gmusic.js

Browser-side JS library for controlling Google Music
The Unlicense
54 stars 7 forks source link

playback.setCurrentTime doesn't work in Chrome extension #17

Open x3haloed opened 7 years ago

x3haloed commented 7 years ago

I'm trying to build a Chrome extension for controlling Google Play Music. I have a content script that includes the gmusic.js library. I'm able to successfully call playback.playPause(), playback.getCurrentTrack(), and extras.getTrackURL(), but playback.setCurrentTime() doesn't seem to be working as expected.

When I run the following code, I expect the playback time to be set to 60 seconds:

gmusic = new GMusic();
gmusic.playback.setPlaybackTime(60000);

Instead, I hear a momentary disruption in play, and it continues to play from where it was before.

The console does not show any JavaScript errors.

Any idea what I could be doing wrong?

jostrander commented 7 years ago

Could be a bug, I don't think we use that regularly except for the web socket API upstream in GPMDP. Will need to repo before confirming.

MarshallOfSound commented 7 years ago

Works fine still inside GPMDP 👍

x3haloed commented 7 years ago

I'm still interested in getting gmusic.js working from a Chrome extension. I figured I should give you an example instead of just complaining. I've attached a sample, barebones Chrome extension with gmusic.js.

gmusic-js-bug.zip

To test:

  1. load it up into Chrome and enable it
  2. browse to play.google.com/music
  3. open the Chrome console
  4. play a song
  5. click the extension icon
  6. notice that the console logs "Setting current time to 1 minute..." and then the song skips a moment and continues playing from it's current position. The code has called gmusic.playback.setPlaybackTime(60000); at this point, and the track should be playing from the 1m mark.

I am running Chrome 56.0.2924.87 (64-bit) on macOS Sierra 10.12.3