Paying next episode

amazon-alexa

#1

I am trying to understand how to handle playing next episode better way, the below code works and plays next episode but there is defect in this.

Approach 1 - When playbacknearlyfinished is called I am setting nextIndex to currentIndex and if user call for next episode it will skip one episode. Now this works fine changes next episode but there is risk when user ask for nextEpisode when current episode about to finish. When does this gets called? I saw sometime it gets called immediately after episode start sometime after it ends.

Approach 2 - When Playbackfinished is called update the currentIndex to nextIndex, while I did wrote code and console does show me update but it only work for 2 song after that second song keep repeating. That means the currentIndex again goes back to 0. Now I tried to figure out how it gets updated but no clue because second song in played from queue and I am not sure how does queue update that index.


#2

As far as I know this is covered in this course:

https://www.jovo.tech/courses/project-3-podcast-player


#3

Thanks @jan ,
I was able to fix it, actually the git project have issue. That project uses currentIndex value in player.js, which is not accessible outside of app.js. That’s why it was failing…


#4

Could you further elaborate where the issue is? There is no currentIndex value in player.js https://github.com/jovotech/jovo-sample-podcast-player/blob/master/src/player.js


#5

My bad it was not player.js it was handler.js. The issue was in handler we were trying to get currentIndex when playback finished on nextepisode. But seems like this value only available in app.js and handler doesn’t get anything and it fail to move to next episode. So i moved this portion of code in app.js and it worked.


#6

Hmm. This should work. Could you take a look @Kaan_Kilic?