Repeat doesn't work when playlists were initialized
Issue description
If the song list was initialized with the "playlists" key in Amplitude.init(), then after clicking to an element with "amplitude-repeat" class, the player does not repeat the playlist. I wrote the steps to reproduce below.
It works when it was initialized with "songs" only (with no multiple playlist) as seen here: https://521dimensions.com/open-source/amplitudejs/docs/examples/blue-playlist.html
Also, repeating a single song (using "amplitude-repeat-song") on a playlist working with no problems, too.
Environment
- What's My Browser Support link: Chrome 93
- Amplitude.js Version: 5.3.2
Steps to reproduce the issue
- Go to https://521dimensions.com/open-source/amplitudejs/docs/examples/multiple-playlists.html
- Click to the repeat button on Playlist 1
- Go back to the previous (last track) called "Offcut # 6"
- Jump to the last few seconds
What is expected?
Expected: After finishing "Offcut # 6", the first song in the playlist (Risin' High) should start.
Actual: After finishing "Offcut # 6", the playback stops after it jumps to the first song.
Link to where issue can be reproduced
https://521dimensions.com/open-source/amplitudejs/docs/examples/multiple-playlists.html
Additional details / screenshots
In src/utilities/audioNavigation.js the setNextPlaylist(playlist) function, the code that decides if it should start the playback checks on the global object.
if (endOfList && !config.repeat) {
} else {
if (!(songEnded && !config.repeat && endOfList)) {
Core.play();
}
}
Shouldn't this check on the current playlist instead? Like that:
if (endOfList && !config.playlists[playlist].repeat) {
} else {
if (!(songEnded && !config.playlists[playlist].repeat && endOfList)) {
Core.play();
}
}