Skip to content

Commit 32777f3

Browse files
authored
Merge pull request #260 from adamint/dev
3.5.06 release - fixes incompatible coroutine versioning
2 parents d9c49aa + 19101c8 commit 32777f3

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ supporting Kotlin/JS, Kotlin/Android, Kotlin/JVM, and Kotlin/Native
3030
+ [SpotifyApiBuilder block & setting API options](#spotifyapibuilder-block--setting-api-options)
3131
* [API options](#api-options)
3232
+ [Using the API](#using-the-api)
33-
* [Platform-specific wrappers and information]("#platform-specific-wrappers-and-information")
33+
* [Platform-specific wrappers and information](#platform-specific-wrappers-and-information)
3434
+ [JavaScript: Spotify Web Playback SDK wrapper](#js-spotify-web-playback-sdk-wrapper)
3535
* [Tips](#tips)
3636
+ [Building the API](#building-the-api)
@@ -385,11 +385,46 @@ for playing music via Spotify in the browser on your own site.
385385
To do this, you need to create a `Player` instance and then use the associated methods to register listeners, play,
386386
and get current context.
387387

388-
**Please see an example of how to do this [here](https://github.com/adamint/spotify-web-api-browser-example/blob/95df60810611ddb961a7a2cb0c874a76d4471aa7/src/main/kotlin/com/adamratzman/layouts/HomePageComponent.kt#L38)**.
388+
Please see an example of how to do this [here](https://github.com/adamint/spotify-web-api-browser-example/blob/95df60810611ddb961a7a2cb0c874a76d4471aa7/src/main/kotlin/com/adamratzman/layouts/HomePageComponent.kt#L38).
389389
An example project, [spotify-web-api-browser-example](https://github.com/adamint/spotify-web-api-browser-example),
390390
demonstrates how to create a frontend JS Kotlin application with Spotify integration and
391391
that will play music in the browser.
392392

393+
**Notes**:
394+
1. You must include the Spotify player JS script by including `<script src="https://sdk.scdn.co/spotify-player.js"></script>`
395+
2. You must define a `window.onSpotifyWebPlaybackSDKReady` function immediately afterwards - this should load your main application bundle.
396+
Otherwise, you will get errors. An example is below:
397+
398+
```html
399+
<html>
400+
<head>
401+
...
402+
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
403+
404+
<script>
405+
jQuery.loadScript = function (url, callback) {
406+
jQuery.ajax({
407+
url: url,
408+
dataType: 'script',
409+
success: callback,
410+
async: true
411+
});
412+
}
413+
</script>
414+
415+
<script src="https://sdk.scdn.co/spotify-player.js"></script>
416+
<script>
417+
window.onSpotifyWebPlaybackSDKReady = () => {
418+
$.loadScript("main.bundle.js")
419+
}
420+
</script>
421+
</head>
422+
<body>
423+
....
424+
</body>
425+
</html>
426+
```
427+
393428
## Tips
394429

395430
### Building the API

build.gradle.kts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,12 @@ kotlin {
173173

174174
targets {
175175
sourceSets {
176-
val coroutineVersion = "1.4.2-native-mt"
177176
val serializationVersion = "1.0.1"
178177
val ktorVersion = "1.5.1"
179178
val korlibsVersion = "2.0.6"
180179

181180
val commonMain by getting {
182181
dependencies {
183-
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"){
184-
version {
185-
strictly(coroutineVersion)
186-
}
187-
}
188182
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion")
189183
implementation("io.ktor:ktor-client-core:$ktorVersion")
190184
implementation("com.soywiz.korlibs.klock:klock:$korlibsVersion")
@@ -264,6 +258,13 @@ kotlin {
264258
dependsOn(commonMain)
265259

266260
dependencies {
261+
val coroutineMTVersion = "1.4.2-native-mt"
262+
263+
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineMTVersion") {
264+
version {
265+
strictly(coroutineMTVersion)
266+
}
267+
}
267268
implementation("io.ktor:ktor-client-curl:$ktorVersion")
268269
}
269270
}

0 commit comments

Comments
 (0)