question

nealrs avatar image
nealrs asked

example of pause -> resume audioplayer

Hiya, I've been hacking on the sample audio player code (single stream) and was wondering how others have / would suggest implement resuming the audio rather than restarting it (as in the example).

I know that I have to passback the offset to the play directive, but I'm unsure of how to store it / what to use (since I'm a node newbie). Appreciate any help / code samples / etc. Thanks!

alexa skills kitaudioaudioplayer
10 |3000 characters needed characters left characters exceeded

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

1 Answer

Jenn@amazon avatar image
Jenn@amazon answered

Check out the Multi-Stream code sample in GitHub.

AudioEventHandlers.js handles saving the offset for you.

With 'PlaybackStopped':

'PlaybackStopped' : function () {
        /*
         * AudioPlayer.PlaybackStopped Directive received.
         * Confirming that audio file stopped playing.
         * Storing details in dynamoDB using attributes.
         */
        this.attributes['token'] = getToken.call(this);
        this.attributes['index'] = getIndex.call(this);
        this.attributes['offsetInMilliseconds'] = getOffsetInMilliseconds.call(this);
        this.emit(':saveState', true);
    }
10 |3000 characters needed characters left characters exceeded

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