Playing music in your visitors Spotify using Safari

Well well, another post about safari! The problem I will take up today is the how Safari handles protocol handlers. In all other major browsers, even Internet Explorer, you have to agree to visit a link with a custom protocol. But not in safari. Oh no.

 

Luckily, programs usually has built in confirmation that will ask you if you really wish to do what the browser is trying to do... But not Spotify. Oh no. You can't favorite songs, add playlists or so. But you can play a song! Believe it or not, this code will start to play a song in Spotify in both Windows and Mac OS:

<script>
document.location = 'spotify:track:0QwzCPyTv6UnzjAhZZ0CkB';
</script>

It will start to play "Firestarter" by Prodigy. While we shouldn't overlook the seriousness in this matter, it could work as a pretty fun prank, playing a song when someone visits your site and make them think "I hate websites with music", they close the tab but the music continues, they close the browser and the music continues! Creepy stuff.

I have another post coming up regarding protocol handlers but meanwhile, have fun with this little Safari/Spotify trick :)

Ciao.

Sup, I'm Mathias and I was born 1991. It feels like I should really write something here.

3 Comments

  1. Henrik Kentsson says:

    This worked for me using Firefox, but probably since all spotify links will start spotify directly.

  2. Mathias says:

    @Henrik:
    In firefox (3.6.11 and 4.0.1 at least), you will get prompted with a question if you would like to send the link to Spotify or not. If you choose to remember your choice for Spotify links, it will have the same effect as in Safari. However, the point was that Safari does not have this "middle-stage" of verification and will launch any link with a protocol linked to an application without verification :)

  3. Mathias Karlsson says:

    @Henrik:
    In firefox (3.6.11 and 4.0.1 at least), you will get prompted with a question if you would like to send the link to Spotify or not. If you choose to remember your choice for Spotify links, it will have the same effect as in Safari. However, the point was that Safari does not have this “middle-stage” of verification and will launch any link with a protocol linked to an application without verification :)

Leave a Comment