question

Leandrock avatar image
Leandrock asked

How to implement Playback Controller Interface in ask python?

Hello people.


I'm having a hard time making the playback controller interface to work. I don't know why the following code is never reached (on Cloudwatch I can't see the INFO).


class PlayCommandHandler(AbstractRequestHandler):

def can_handle(self, handler_input):

# type: (HandlerInput) -> bool

return is_request_type("PlaybackController.PlayCommandIssued")(handler_input)

def handle(self, handler_input):

# type: (HandlerInput) -> Response

logger.info("In PlayCommandHandler")

return <AUDIO_PLAYER_DIRECTIVES>



I have it added to skillbuilder:

sb.add_request_handler(PlayCommandHandler())



The code I'm using is based on this one:


https://github.com/alexa/skill-sample-python-audio-player/blob/master/SingleStream/lambda/py/lambda_function.py


I've read many documentation on PlaybackCommand, I know that the pause button on Echo devices treats it locally. But I can't make the play (resume) button work.

I also checked this blog post, but unfortunatelly it's example code is in nodejs.


https://developer.amazon.com/blogs/alexa/post/62a7cb0c-01b0-4393-888a-7156e8717f3e/how-to-handle-touch-screen-controls-for-audio-skills-on-echo-show-and-echo-spot


Other strange thing that I noted on my skill is that the PlaybackStartedHandler also does't register any logs on CloudWatch.


class PlaybackStartedHandler(AbstractRequestHandler):

def can_handle(self, handler_input):

# type: (HandlerInput) -> bool

return is_request_type("AudioPlayer.PlaybackStarted")(handler_input)

def handle(self, handler_input):

# type: (HandlerInput) -> Response

logger.info("In PlaybackStartedHandler")

logger.info("Playback started")

return handler_input.response_builder.response


Isn't it supposed to log "In PlaybackStartedHandler" and "Playback started" when the audio starts?


I would appreciate any help on making the echo show play button work. It's the only thing left to certificate my skill.


Thank you very much!

submission testing certificationpythonask sdk
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Leandrock avatar image
Leandrock answered

UPDATE: I was able to fix it! It was the sdk version, I was using an older version and updating it with pip resolved the issue. Before the sdk update, I was't able to get into the PlaybackStartedHandler. After that, worked fine!

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.