berrberr / streamkeys

Global media player hotkeys for chrome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AmazonController.js defeats Play/Pause key press on Mac

mwarrenus opened this issue · comments

When StreamKeys is enabled for Amazon Music (AmazonController.js), pressing the Play/Pause button on the Macbook TouchBar or pressing the keyboard Play/Pause key (F8) causes SteamKeys to issue a duplicate click on the music player's ".playbackControlsView .playButton" button. The duplicate click defeats the original keypress' toggle action (if music is playing, it continues playing; if it's paused, it remains paused).

For example, tapping the TouchBar pause symbol (playing state) cause the symbol to flash to the play symbol (paused state) and then it immediately goes back to the pause symbol (playing state). Here are the console message leading up to the error (last row, bold):

Message Details Source
STREAMKEYS-INFO: Attached listener for BaseControllerbuttonSwitch: falsehidePlayer: trueoldState: {song: "A Fifth of Beethoven", artist: "Henry Mancini", album: null, art: "https://album-art-storage-us.s3.amazonaws.com/d45b...31c31441df6b5012aee96cbc0951651fb9ccd6412def9b6fa", currentTime: null, ...}overridePlayNext: falseoverridePlayPause: falseoverridePlayPrev: falseselectors: {playPause: ".playbackControlsView .playButton", play: null, pause: null, playNext: ".playbackControlsView .nextButton", playPrev: ".playbackControlsView .previousButton", ...}siteName: "Amazon Music"proto: Object AmazonController.js:345
STREAMKEYS-INFO: SK content script loaded AmazonController.js:345
Unchecked runtime.lastError: The message port closed before a response was received. VM2261 home:1
STREAMKEYS-INFO: Player state change AmazonController.js:345
Ractive.js: Missing "focusout" events plugin. You may need to download a plugin via http://docs.ractivejs.org/latest/plugins#eventss WebPlayer.vendors.9bed9b08cd7c59c8efcf.js:44
STREAMKEYS-INFO: Player state change AmazonController.js:345
STREAMKEYS-INFO: playPause AmazonController.js:345

I set a breakpoint on AmazonController.js:147 and found that when execution pauses there the player is already paused and the TouchBar is in the correct state. The call to this.click(action: "playPause" ...) then causes the music to resume playing instead of leaving it paused as desired.

139 BaseController.prototype.playPause = function() {
140    if(this.selectors.play !== null && this.selectors.pause !== null) {
141      if(this.isPlaying()) {
142        this.click({action: "playPause", selectorButton: this.selectors.pause, selectorFrame: this.selectors.iframe});
143      } else {
144        this.click({action: "playPause", selectorButton: this.selectors.play, selectorFrame: this.selectors.iframe});
145      }
146    } else {
147      this.click({action: "playPause", selectorButton: this.selectors.playPause, selectorFrame: this.selectors.iframe});
148    }
149  };

Edit to add version info: browser Chrome 84.0.4147.125 (Official Build) (64-bit), MacOS 10.15.6
I also notice that, at the breakpoint, this.selectors.playState is .playbackControlsView .playerIconPause.

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.