Reputation: 107
I'm writing a simple Alexa Skill that utilizes AudioPlayer to play a long audio file. This StackOverflow answer nicely demonstrates the use of directives to play (and stop) audio, but I'm not quite sure how to intercept AudioPlayer events like PlayBackStopped and PlayBackPaused. Basically I'm trying to let the user pause an audio stream and then resume playing where they last left off. Any examples in Python would be very welcome!
Upvotes: 1
Views: 579
Reputation: 1009
I'm not quite sure how to intercept AudioPlayer events like PlayBackStopped and PlayBackPaused
Events such as PlaybackPaused are Audio requests notifying the player about the state. So whenever a user pauses in an active session, you will get two events one is STOP and other is PlayBackPaused.
I'm trying to let the user pause an audio stream and then resume playing where they last left off
So whenever you get PlayBackStopped you also get offset in milliseconds. You can take that offset and store in DynamoDB or any persistent storage. When the user returns just check is he has any offset and start from there.
Example of python ask-SDK multistream audio player.
Upvotes: 1