Skip to content

Commit 19101c8

Browse files
committed
fix coroutine versioning
Signed-off-by: Adam Ratzman <[email protected]>
1 parent 52d9b6e commit 19101c8

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
@@ -29,7 +29,7 @@ supporting Kotlin/JS, Kotlin/Android, Kotlin/JVM, and Kotlin/Native
2929
+ [SpotifyApiBuilder block & setting API options](#spotifyapibuilder-block--setting-api-options)
3030
* [API options](#api-options)
3131
+ [Using the API](#using-the-api)
32-
* [Platform-specific wrappers and information]("#platform-specific-wrappers-and-information")
32+
* [Platform-specific wrappers and information](#platform-specific-wrappers-and-information)
3333
+ [JavaScript: Spotify Web Playback SDK wrapper](#js-spotify-web-playback-sdk-wrapper)
3434
* [Tips](#tips)
3535
+ [Building the API](#building-the-api)
@@ -384,11 +384,46 @@ for playing music via Spotify in the browser on your own site.
384384
To do this, you need to create a `Player` instance and then use the associated methods to register listeners, play,
385385
and get current context.
386386

387-
**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)**.
387+
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).
388388
An example project, [spotify-web-api-browser-example](https://github.com/adamint/spotify-web-api-browser-example),
389389
demonstrates how to create a frontend JS Kotlin application with Spotify integration and
390390
that will play music in the browser.
391391

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

394429
### 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)