How to play music with endpoint me/player/play in jetpackcompose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Headers("Authorization: Bearer ${Constants.AUTHORIZATION_HEADER}")
@PUT("v1/me/player/play")
fun play(
@Header("Content-Type") contentType: String,
@Body body: PlayRequestBody
) : Call<Void>
ViewModel
fun playMusic(contextUri: String) {
val requestBody = PlayRequestBody(
context_uri = "spotify:album:5ht7ItJgpBH7W6vJ5BqpPr",
offset = Offset(position = 5),
position_ms = 0
)
soundSphereApiService.play(contentType = "application/json", body = requestBody).enqueue(object : Callback<Void> {
override fun onResponse(call: Call<Void>, response: Response<Void>) {
Log.d("PlayViewModel", "playMusic: ${response.isSuccessful}")
if (response.isSuccessful) {
Log.d("PlayViewModel", "playMusic: ${response.body().toString()}")
} else {
Log.e("PlayViewModel", "playMusic: ${response.code()}")
}
}
override fun onFailure(call: Call<Void>, t: Throwable) {
//Log.e("PlayViewModel", "playMusic: ${t.message}")
}
})
}
Labels:
- Labels:
-
Feature Request
-
Help
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page