Announcements
The Spotify Stars Program: Celebrating Values Week!

Help Wizard

Step 1

NEXT STEP

Spotify SDK doesn't seem compatible with SharePoint framework anymore

Spotify SDK doesn't seem compatible with SharePoint framework anymore

We are a team of developers working on a product based on the SharePoint framework. The product we are working on has a couple of API integrations and one of them is Spotify's web player that is implemented using Spotify's Web SDK. A few months back our Spotify SDK-based web player was working fine however recently it has started encountering a serious issue when the page tries to load the SDK using the following CDN path ends up in an issue with the following stack trace.

https://sdk.scdn.co/spotify-player.js

spotify-player.js:18 Uncaught TypeError: r.__extends is not a function
at spotify-player.js:18
at Object.6.tslib (spotify-player.js:18)
at s (spotify-player.js:3)
at spotify-player.js:3
at Object.7.../enums/errors (spotify-player.js:18)
at s (spotify-player.js:3)
at e (spotify-player.js:3)
at spotify-player.js:3

 

Plan

Premium

Country

Australia

Device

Chrome Desktop browser

Operating System

Windows 10

 

My Question or Issue

 

spotify_issue.png
Reply
1 Reply

I got this error too in Flutter Web, when using this: https://pub.dev/packages/spotify_sdk

I was able to work around it by downloading spotify-player.js in index.html:

<script src="https://sdk.scdn.co/spotify-player.js"></script>
<script>
window.onSpotifyWebPlaybackSDKReady = (evt) => {

};
</script>

Internally, when calling a spotify_sdk function for the first time, it initializes the Spotify SDK by injecting an onSpotifyWebPlaybackSDKReady function and adding <script src="https://sdk.scdn.co/spotify-player.js"></script> to the HTML.

Then, it waits until its injected onSpotifyWebPlaybackSDKReady function is called, and then sets an internal flag (_sdkLoaded) to indicate that the SDK has been initialized. Because of the JS error - onSpotifyWebPlaybackSDKReady is never called and spotify_sdk gets stuck in an infinite loop.

However, before spotify_sdk attempts to initialize the SDK, it checks to see if an onSpotifyWebPlaybackSDKReady function had already been installed. If it was - it skips the initialization and directly sets the "SDK loaded" flag.

So the above code seems to fix the issue, but it's important to not call spotify_sdk functions until the Spotify SDK is actually initialized (i.e. because spotify_sdk no longer takes care of that).

Suggested posts