twolfson / google-music.js

Browser-side JS library for controlling Google Music
The Unlicense
47 stars 6 forks source link

Add new event, on('start:song') #43

Open MarshallOfSound opened 8 years ago

MarshallOfSound commented 8 years ago

Currently if you listen to a song on repeat, the change:song event is never fired, because technically, the song has never changed.

I'm putting it out there for discussion that in this case (a song has been restarted) we should re-fire the event change:song. This will be a more logical event system as although the song hasn't changed, the spirit of the event is to fire when a new song starts playing.

The main usage of this event as far as I can tell is to display the track information remotely (somewhere not inside Google Play Music or to scrobble to last.fm).

Interested as to what you people think

/cc @gmusic-utils/gmusic-js

twolfson commented 8 years ago

I think that's counter intuitive to the name "change". Maybe we should have a "song-start", "song-end", or "change:song-playcount" event (we would need to figure out when Google bumps their play counter for songs)?

MarshallOfSound commented 8 years ago

Yeah, the name change doesn't quite fit with my wanted purpose. I like the idea of a new song-start event though. That would be easy to track, every time the progress bar is at position 0 we fire the song-start event.

Does that sound about right?

twolfson commented 8 years ago

Yea, that sounds right. As a user though, it feels a bit weird to register a play count so eagerly (sometimes I remember a song sound but only its album so I am playing 10 seconds of each track). But if your current Last.fm scrobbler is using change:song then the behavior is the same and probably acceptable.

MarshallOfSound commented 8 years ago

The scrobbler follows the last.fm spec which says you have to wait for the song to play to 50% or 3 minutes, which ever comes first. So I use change:song to start the timer. Changing that to song-start would fix https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/issues/1061

twolfson commented 8 years ago

Ahhh, I see. song-start sounds good to me then :+1: What are your thoughts on namespacing for consistency with change (e.g. start:song)?

MarshallOfSound commented 8 years ago

I would however suggest that we internally throttle the song-start event to only fire a maximum of once every few seconds. Because otherwise the multifiring nature of change:playback-time will get quite fustrating

MarshallOfSound commented 8 years ago

Yep, that namespacing makes sense 👍

twolfson commented 8 years ago

Agreed :+1:

MarshallOfSound commented 8 years ago

Oops, bad button presses