0

Is there a way via JavaScript to see if a person has Spotify installed on their machine. Reason being, if they do, I will share some Spotify URI's on my page (example... spotify:user:124792730:playlist:0Y2wUYw5wxMdZGCqJyqbaA). If they don't, I would prompt them to install Spotify so they can listen to the Spotify URI's instead of serving them broken links.

There is a way to do this for Spotify APPS. But What if I'm not making an app, I just want to serve Spotify URI links from web page only if they have Spotify already.

Update: The following seems to only work on Firefox. I think I'm close, though.

    <script type="text/javascript">
        try {
            location.replace("spotify:user:124792730:playlist:0Y2wUYw5wxMdZGCqJyqbaA");
        } catch (e) {
            alert("You don't have spotify Installed.");
        }

    </script>
mrbinky3000
  • 4,055
  • 8
  • 43
  • 54

1 Answers1

2

You could link to the HTTP version instead:

http://open.spotify.com/user/124792730/playlist/0Y2wUYw5wxMdZGCqJyqbaA

This presents a link to open the playlist in Spotify along with the option to install it.

James M
  • 18,506
  • 3
  • 48
  • 56
  • 1
    The benefit of a Spotify URI over a Spotify HTTP link is that the URI opens the target playlist or song directly in Spotify. The HTTP method is a two step process that first takes people to a web page where they can then click on a link. I'm trying to avoid two steps for folks who already have Spotify. – mrbinky3000 Jan 18 '12 at 19:38
  • 1
    You know, this option is looking better all the time. If the user says "Yes I Have Spotify" once, they don't have to do it ever again unless they delete the cookies for ".spotify.com" Unfortunately, they still have to have two windows open. I wish I could detect if that cookie is set already from my domain. – mrbinky3000 Jan 18 '12 at 20:37
  • 1
    Check the source of this page to see how we automatically launch the client once the user has clicked "I Have Spotify" once: view-source:http://open.spotify.com/album/2PpT0B9E0IglzKhOZfMbQC – mager Jan 19 '12 at 14:33