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.