Created
April 18, 2021 17:09
-
-
Save kinisoftware/564aefff2539a9b7fdb4ea13c851c678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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