Skip to content

Commit c2a4ef3

Browse files
authored
Merge pull request #297 from adamint/dev
fix js web playback sdk, add Player.activeElement, add from_token in market
2 parents ce6e2e3 + 2439916 commit c2a4ef3

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/endpoints/pub/BrowseApi.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ public class BrowseApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
7676
offset: Int? = null,
7777
market: Market? = null
7878
): PagingObject<SimpleAlbum> = get(
79-
endpointBuilder("/browse/new-releases").with("limit", limit).with("offset", offset).with(
80-
"country",
81-
market?.name
82-
).toString()
79+
endpointBuilder("/browse/new-releases").with("limit", limit)
80+
.with("offset", offset).with("country", market?.name).toString()
8381
).toNonNullablePagingObject(SimpleAlbum.serializer(), "albums", api = api, json = json)
8482

8583
/**
@@ -281,11 +279,10 @@ public class BrowseApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
281279
offset: Int? = null,
282280
market: Market? = null
283281
): PagingObject<SimplePlaylist> = get(
284-
endpointBuilder("/browse/categories/${categoryId.encodeUrl()}/playlists").with(
285-
"limit",
286-
limit
287-
).with("offset", offset)
288-
.with("market", market?.name).toString()
282+
endpointBuilder("/browse/categories/${categoryId.encodeUrl()}/playlists")
283+
.with("limit", limit)
284+
.with("offset", offset)
285+
.with("country", market?.name).toString()
289286
).toNonNullablePagingObject((SimplePlaylist.serializer()), "playlists", api = api, json = json)
290287

291288
/**

src/commonMain/kotlin/com.adamratzman.spotify/models/ResultObjects.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public data class ErrorObject(val status: Int, val message: String, val reason:
129129
@Serializable
130130
public data class AuthenticationError(
131131
val error: String,
132-
@SerialName("error_description") val description: String
132+
@SerialName("error_description") val description: String? = null
133133
)
134134

135135
/**

src/commonMain/kotlin/com.adamratzman.spotify/utils/Market.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ public enum class Market(
18491849
/**
18501850
* A special Market for endpoints to return content available in the user's own market
18511851
*/
1852-
from_token("from_token", "ZZZ", 999, Assignment.NOT_USED);
1852+
FROM_TOKEN("from_token", "ZZZ", 999, Assignment.NOT_USED);
18531853

18541854
/**
18551855
* Code assignment state in [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1).

src/jsMain/kotlin/com/adamratzman/spotify/webplayer/WebPlaybackSdk.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public external interface PlaybackTrackWindow {
103103
*/
104104
public external interface PlayerInit {
105105
public var name: String
106-
public fun getOAuthToken(cb: (token: String) -> Unit)
106+
public var getOAuthToken: (cb: (token: String) -> Unit) -> Unit
107107
public var volume: Number?
108108
get() = definedExternally
109109
set(value) = definedExternally
@@ -132,6 +132,14 @@ public open external class Player(options: PlayerInit) {
132132
*/
133133
public open fun getCurrentState(): Promise<PlaybackState?>
134134

135+
/**
136+
* Some browsers prevent autoplay of media by ensuring that all playback is triggered by
137+
* synchronous event-paths originating from user interaction such as a click.
138+
* This event allows you to manually activate the element if action is deferred or done
139+
* in a separate execution context than the user action.
140+
*/
141+
public fun activateElement(): Promise<Any>
142+
135143
/**
136144
* Get the local volume currently set in the Web Playback SDK.
137145
* @return Returns a Promise containing the local volume (as a Float between 0 and 1).

0 commit comments

Comments
 (0)