Closed kevinApplaud closed 6 years ago
I need to play a list of mp3 urls.
Right now, when using your template then: PlaybackNearlyFinished triggers too early, I need to play a list of mp3 files. But It only plays them for 1 sec and then plays next one for 1 sec etc...
"use strict"; // ================================================================================= // App Configuration // ================================================================================= const { App } = require("jovo-framework"); const config = { logging: true, intentMap: { "AMAZON.PauseIntent": "PauseIntent", "AMAZON.ResumeIntent": "ResumeIntent" } }; const app = new App(config); let mp3Arr; let currentMp3Count = 0; app.setHandler({ LAUNCH: function() { this.toIntent("PlayIntent"); }, PlayIntent: function() { mp3Arr = [ "https://s3.amazonaws.com/jovo-songs/song1.mp3", "https://s3.amazonaws.com/jovo-songs/song1.mp3" ]; this.alexaSkill() .audioPlayer() .setOffsetInMilliseconds(0) .play(mp3Arr[currentMp3Count], "token") .tell("Playing news"); }, PauseIntent: function() { this.alexaSkill() .audioPlayer() .stop(); this.tell("Paused!"); }, ResumeIntent: function() { this.alexaSkill() .audioPlayer() .setOffsetInMilliseconds(0) .play(news[currentNews].url, "token") .tell("Resuming!"); }, StopIntent: function() { console.log("StopIntent"); this.endSession(); }, AUDIOPLAYER: { "AudioPlayer.PlaybackStarted": function() { console.log("AudioPlayer.PlaybackStarted"); this.endSession(); }, "AudioPlayer.PlaybackNearlyFinished": function() { console.log("AudioPlayer.PlaybackNearlyFinished"); currentMp3Count++; if (currentMp3Count < mp3Arr.length) { this.alexaSkill() .audioPlayer() .setOffsetInMilliseconds(0) .play(mp3Arr[currentMp3Count], "token"); } else { currentMp3Count = 0; this.toIntent("StopIntent"); } }, "AudioPlayer.PlaybackFinished": function() { console.log("AudioPlayer.PlaybackFinished"); this.endSession(); }, "AudioPlayer.PlaybackStopped": function() { console.log("AudioPlayer.PlaybackStopped"); this.endSession(); } } }); module.exports.app = app;
Answered here https://github.com/jovotech/jovo-framework-nodejs/issues/244
I need to play a list of mp3 urls.
Right now, when using your template then: PlaybackNearlyFinished triggers too early, I need to play a list of mp3 files. But It only plays them for 1 sec and then plays next one for 1 sec etc...
Code