SynQApp / Extension

Your music companion for the web, with a portable mini player and the ability to listen to any music link on your preferred service!
https://www.synqapp.io
Apache License 2.0
24 stars 2 forks source link

Spotify and Amazon Music autoplay fix #14

Closed tekkeon closed 11 months ago

tekkeon commented 11 months ago

Overview

When you load up Spotify or Amazon Music, the player is already loaded with music ready to go (unlike YouTube and Apple Music). Opening the SynQ mini player and pressing play to get the loaded music going did not work because browsers block audio autoplay without the user first interacting with the page (click, press, keypress, etc). As such, we needed to detect when the player was loaded and ready and then embed a button on the page that the user can press, enabling autoplay. Additionally, using the Spotify and Amazon Music APIs only seem to become enabled once a native button press happens. As such, when the user presses the embedded button, the extension will simulate a click to initialize the players.

Note that this is an edge case. Generally, the user will begin listening to music before opening the mini player, and ideally they'll learn naturally that doing that allows them to not have to deal with this popup. But for the low rate of cases where this does happen, this PR solves it.

User Flow and Screenshots

  1. Opening the SynQ mini player when the player is not loaded displays this message:

image

  1. Clicking the button sends them to the selected tab, where they see this popup:

image

  1. Clicking outside of the popup dismisses the popup and does nothing
  2. Clicking the enable button causes the user to interact with the page, enabling autoplay, and the extension then clicks the play/pause button twice to enable the player.
tekkeon commented 11 months ago

Yeah that's actually exactly what this TODO comments was for lol: https://github.com/SynQApp/Extension/pull/14/files#diff-08b2395b22df5b80e3a4d98fcbe616db9a91811741b8a7231f2a6357746a6a4aR396

I'm fixing it in my next PR since I didn't have toggleMute implemented in the controllers yet lol.