Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioPlayer.PlaybackNearlyFinished triggers too early #244

Closed
1 of 4 tasks
kevinApplaud opened this issue Sep 2, 2018 · 1 comment
Closed
1 of 4 tasks

AudioPlayer.PlaybackNearlyFinished triggers too early #244

kevinApplaud opened this issue Sep 2, 2018 · 1 comment

Comments

@kevinApplaud
Copy link

I'm submitting a...

  • Bug report
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Expected Behavior

I need to play a list of mp3 urls.

Current Behavior

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

"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;

Your Environment

  • Jovo Framework version used: 1.0.0
  • Operating System: MacOS High Sierra
@jankoenig
Copy link
Member

Hi @kevinApplaud,

We can't do anything about requests being triggered too early, as they're coming from the Alexa platform, not from the Jovo Framework. Are you using an Echo Spot for testing? We noticed a few months ago that this device isn't as reliable as others regarding audioplayer requests.

Here are a few things I'd suggest:

Closing this as it's not a bug. Let me know if you have any more questions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants