'Alexa custom skill audio directive resume previous music playback
I am writing a simple skill that plays some MP3 files when launched. I have this working but if there was some music playback previously on the echo device it does not resume after my skill has finished. How do I resume my previous music session (play back from Spotify if that is relevant) Here is the relevant part of my code
def handle(self, handler_input):
# type: (HandlerInput) -> Response
logger.info("In Noise handler")
url = random.choice(noises_urls)
handler_input.response_builder.add_directive(
PlayDirective(
play_behavior=PlayBehavior.REPLACE_ALL,
audio_item=AudioItem(
stream=Stream(
token=url,
url=url,
offset_in_milliseconds=0,
expected_previous_token=None),
metadata=None
)
)
).set_should_end_session(True)
return handler_input.response_builder.response
I have tried changing Play behaviour to REPLACE_ENQUEUED and ENQUEUE but these does not play my audio file immediately.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
