Skip to content

Instantly share code, notes, and snippets.

@kinisoftware
Created January 5, 2021 07:50
Show Gist options
  • Save kinisoftware/cc19d75475b623cbfe676cb6517ce28b to your computer and use it in GitHub Desktop.
Save kinisoftware/cc19d75475b623cbfe676cb6517ce28b to your computer and use it in GitHub Desktop.
class PlaybackFailureHandler : RequestHandler {
override fun canHandle(input: HandlerInput) =
input.matches(Predicates.requestType(PlaybackFailedRequest::class.java))
override fun handle(input: HandlerInput): Optional<Response> {
val request = input.requestEnvelope.request
val intentRequest = request as PlaybackFailedRequest
return when (intentRequest.error.type) {
ErrorType.MEDIA_ERROR_INTERNAL_DEVICE_ERROR -> input.responseBuilder.build()
else -> PlayAudioResponseBuilder.buildFallbackResponse(input)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment