Hi @jaydrogers, Hi @danpastori
I use v5.3.1 and my problem if with start_song parameter itself. My problem is most related with the original github issue than this topic.
Quick exemple:
let init_conf = {
"continue_next": false,
"preload": "metadata",
"songs": finalPlaylist,
"start_song": 1,
"callbacks": {
"initialized": function() {
...
},
"ended": () => {
let nextEpisode = document.querySelector("[data-index='"+(Amplitude.getActiveIndex() + 1) +"']");
if (nextEpisode != null) {
let url = nextEpisode.querySelector('a.play').href;
if (url != null) {
window.open(url, '_self');
}
}
}
}
};
Amplitude.init(init_conf);
As you can see with “ended” event, i want to load a specific url for each song (SEO…), so if i a am on the 2nd audio page, i want to set player on the 2nd media (index 1).
finalPlaylist is an array of 4 songs, but, even with “start_song”: 1, it will play song index 0 on each page.
The reason is the condition in amplitude.js: amplitudejs/amplitude.js at 745583f1361a93fce1cd298d7fc86915cc1f20ac · serversideup/amplitudejs · GitHub
without the starting_playlist parameter, start_song has no effect, while starting_playlist is useless here. If i use a custom amplitude.js without the starting_playlist test, start_song works as espected.
For moment, the workaround is to call Amplitude.playSongAtIndex(1) in initialized callback, but it’s not a good solution:
- When player is displayed, i see the first song metatada, then, few seconds later, the player display the right metadata, this is not a good user experience.
- playSongAtIndex trigger song_change event, and this is irrelevent in this use case
Thanks