Akshay
Akshay

Reputation: 2229

Spotify Web Playback SDK Integration

I'm trying to build a way to play songs via spotify playback SDK. However, unfortunately I'm stuck on the first step itself.

Here's the documentation I am following.

https://developer.spotify.com/documentation/web-playback-sdk/reference/#api-spotify-player

The problem is, it's not even initialising the SDK. Here's the code that I've written.

<!DOCTYPE html>
<html>
<head>
  <title>Spotify Web Playback SDK Quick Start Tutorial</title>
</head>
<body>
  <h1>Spotify Web Playback SDK Quick Start Tutorial</h1>
  <h2>Open your console log: <code>View > Developer > JavaScript Console</code></h2>

  <script src="https://sdk.scdn.co/spotify-player.js" type="javascript"></script>
    <script>
    window.onSpotifyWebPlaybackSDKReady = () => {
      // You can now initialize Spotify.Player and use the SDK
      alert("Test");
      }
    </script>

</body>
</html>

However, it's not even alerting "Test". What am I doing wrong in here?

Upvotes: 1

Views: 1610

Answers (1)

Dinosan0908
Dinosan0908

Reputation: 1102

You will find it strange but I managed to get it working by removing the type="javascript" when importing the file.

<!DOCTYPE html>
<html>
<head>
  <title>Spotify Web Playback SDK Quick Start Tutorial</title>
</head>
<body>
  <h1>Spotify Web Playback SDK Quick Start Tutorial</h1>
  <h2>Open your console log: <code>View > Developer > JavaScript Console</code></h2>

  <script src="https://sdk.scdn.co/spotify-player.js"></script>
    <script>
    window.onSpotifyWebPlaybackSDKReady = () => {
      // You can now initialize Spotify.Player and use the SDK
      alert("Test");
      }
    </script>

</body>
</html>

So this works

Upvotes: 1

Related Questions