Add-on to automatically click audio play?

Hey guys,

I’ll try to explain you what I’m looking for.
The target is to start automatically an audio player by the browser tab after open or refresh a page, maybe a playlist or album in a music streaming service webplayer. So I’m searching for a possibility to start an audio web player like spotify, deeper or similar.

I’m a musician editor and for me it’s so much more easier, if I find a new album from an artist, maybe on spotify, deezer, tidal or wherever, when the audio starts automatically. I lose so many time per day to click on the album and locate the track name and click again to play. So if I have a add-on what’s stars alone and i can let it go my mouse and do other things.

Now my question, there is an add-on in Firefox, or maybe in a other browser too,…

Which recognize, on this page is an audio file to play, or here is an play command/button and can activate this link?? As it were "click the play button automatically, without to use my mouse "

I’ve found an add-on, calls reloadMatic there can refresh and start the website by a link if you want. But the normal webplayer from spotify, deezer and other, don’t use a audio file behind the play button. So it starts only the player album page but not the music.

I hope my English is not too bad and you understand my problem, it would be great, if you have an idea how could I do that.

Greats, Michael

Hello Michael,
Could you paste here some specific example pages (or all pages) where you would like to auto-play the audio.
Maybe simple Greasemonkey script would be enough for finding and auto-playing an audio element.

Hello juraj.masiar, thanks for replay…

That’s easy, you can visit any streaming service, maybe like spotify, that’s the master of disaster :joy::joy: here you can open any playlist or any album from any artist, maybe like this: https://open.spotify.com/playlist/37i9dQZEVXbMDoHDwVN2tF

That’s the playlist: global top 50, and what would be great, if this playlist starts alone, after open this page. I think all streaming services are the same and work with an webplayer by java. So I think, if it’s work on spotify, it works all over.

The problem of that, that’s are no direct audio files, they are all linked via javascript. That’s it, why I’m looking for an script who find a play command on this page what’s open that automatically.

EDIT:
i will check your plugin idea, maybe in combination with an start script to open play, or skip next, it would be works. But how can i set it? I´ve checked the scripts with this plugin by open the spotify album/playlist page, but nothing is listed like my problem.

greats

First of all, these days all modern web sites are using HTML5 and JavaScript, thankfully there is no Java anymore on the web :smiley:.

If there is no such solution yet, we can create our own, but it needs to be specific for each page. For example for the Spotify you could use the following custom script (use it through Greasemonkey or other user-script manager addon, like the brand new FireMonkey
The script:

// ==UserScript==
// @name     Auto-Play Spotify
// @version  1
// @grant    none
// @include  https://open.spotify.com/*
// ==/UserScript==

const PLAY_BUTTON_SELECTOR = '.tracklist > div:first-child svg.icon-play';

window.addEventListener('load', play);
WatchFunction(() => location.href, play);   // Spotify is a web-application, this script will run only once, we need to watch for URL change and then play again!

async function play() {
  const playButton = await getPlayButton();
  playButton.dispatchEvent(new MouseEvent('click', {view: window, bubbles: true, cancelable: true}));
}

async function getPlayButton() {
  while (true) {
    const button = document.querySelector(PLAY_BUTTON_SELECTOR);
    if (button) return button;
    await timeoutPromise(500);
  }
}

function timeoutPromise(delay) {
  return new Promise(resolve => setTimeout(resolve, delay));
}

function WatchFunction(watchFn, onChangeFn, interval = 150) {
  let _lastValue = watchFn();
  window.setInterval(() => {
    const newValue = watchFn();
    if (_lastValue === newValue) return;
    onChangeFn(newValue, _lastValue);
    _lastValue = newValue;
  }, interval)
}

Note few things though:

  1. Firefox 68 (maybe even 67?) blocks auto-play audio, so you will have to disable that for Spotify else the script won’t work (you will see the small icon in the URL bar on the left)

  2. To make it work on other pages, just change the URL in the “@include” and change PLAY_BUTTON_SELECTOR. Other than that, it should work - the script waits for the play button to appear on the page and then generates fake “click” event to it.

  3. current script looks for the play button on the very first song on the list - it doesn’t check whether you have already listening for something, it will just play it

  4. the Spotify is actually a web-application (it means that the page won’t reload when you click on some album), so the script actually checks the URL for changes and then looks for a play button again.

1 Like

Ok, thanks for your replay, sounds good…i will check this and try… Unfortunately I’m a absolutely noob guy in programming and coding, that’s why I’m use help from a profi. :slight_smile:

Thanks for your example, now I will try to test it.

Greats from Germany