Skip to content

Instantly share code, notes, and snippets.

@kinisoftware
Created April 18, 2021 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinisoftware/564aefff2539a9b7fdb4ea13c851c678 to your computer and use it in GitHub Desktop.
Save kinisoftware/564aefff2539a9b7fdb4ea13c851c678 to your computer and use it in GitHub Desktop.
fun HandlerInput.buildPlayResponse(audioStream: AudioStream): Optional<Response> {
val stream = Stream.builder()
.withOffsetInMilliseconds(audioStream.offsetInMilliseconds)
.withExpectedPreviousToken(null)
.withToken(audioStream.streamToken)
.withUrl(audioStream.file)
.build()
val audioItem = AudioItem.builder()
.withMetadata(
AudioItemMetadata.builder()
.withTitle(audioStream.title)
.withArt(
Image.builder().addSourcesItem(
ImageInstance.builder()
.withUrl(audioStream.imageSmall).build()
).build()
)
.withBackgroundImage(
Image.builder().addSourcesItem(
ImageInstance.builder()
.withUrl(audioStream.image)
.build()
).build()
)
.build()
)
.withStream(stream)
.build()
val playDirective = PlayDirective.builder()
.withPlayBehavior(PlayBehavior.REPLACE_ALL)
.withAudioItem(audioItem)
.build()
return responseBuilder
.addDirective(playDirective)
.build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment