Paying next episode



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.


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


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…


Could you further elaborate where the issue is? There is no currentIndex value in player.js


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.


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