Created
April 11, 2021 15:44
-
-
Save kinisoftware/0e6a219ffec67bd44b1e8c9d2d198d06 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class PlaybackStoppedHandler : RequestHandler { | |
override fun canHandle(input: HandlerInput) = | |
input.matches(Predicates.requestType(PlaybackStoppedRequest::class.java)) | |
override fun handle(input: HandlerInput): Optional<Response> { | |
val request = input.requestEnvelope.request | |
val intentRequest = request as PlaybackStoppedRequest | |
val lastPlayedAudio = JacksonSerializer().deserialize( | |
input.attributesManager.persistentAttributes["lastPlayedAudio"] as String, | |
Audio::class.java | |
) | |
input.attributesManager.persistentAttributes["lastPlayedAudio"] = | |
JacksonSerializer().serialize( | |
lastPlayedAudio.copy(lastPlayedOffsetInMilliseconds = intentRequest.offsetInMilliseconds) | |
) | |
input.attributesManager.savePersistentAttributes() | |
return input.responseBuilder.build() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment