-
-
Notifications
You must be signed in to change notification settings - Fork 424
Open
Labels
Bug: Needs Confirmation 🧐Bugs that are reported, but needs to be confirmed and replicated.Bugs that are reported, but needs to be confirmed and replicated.
Description
Issue Description
Sometimes I want o know next song that i can pre/background-processing.
ex: Preload media file for smooth playing.
Expected Behavior
Add to public API
Steps To Reproduce
I saw this code to get it
amplitudejs/src/utilities/audioNavigation.js
Lines 100 to 151 in 65a072d
| if (config.repeat_song) { | |
| /* | |
| If the playlist is shuffled, get the now playing index. | |
| */ | |
| if (config.shuffle_on) { | |
| nextIndex = config.shuffle_list[config.active_index].index; | |
| nextSong = config.shuffle_list[nextIndex]; | |
| } else { | |
| nextIndex = config.active_index; | |
| nextSong = config.songs[nextIndex]; | |
| } | |
| } else { | |
| /* | |
| If the shuffle is on, we use the shuffled list of | |
| songs to determine our next song. | |
| */ | |
| if (config.shuffle_on) { | |
| /* | |
| If the active shuffle index + 1 is less than the length, then | |
| we use the next shuffle otherwise we go to the beginning | |
| of the shuffle list. | |
| */ | |
| if (parseInt(config.active_index) + 1 < config.shuffle_list.length) { | |
| /* | |
| Set the next index to be the index of the song in the shuffle list. | |
| */ | |
| nextIndex = parseInt(config.active_index) + 1; | |
| } else { | |
| nextIndex = 0; | |
| endOfList = true; | |
| } | |
| nextSong = config.shuffle_list[nextIndex]; | |
| } else { | |
| /* | |
| If the active index + 1 is less than the length of the songs, then | |
| we use the next song otherwise we go to the beginning of the | |
| song list. | |
| */ | |
| if (parseInt(config.active_index) + 1 < config.songs.length) { | |
| nextIndex = parseInt(config.active_index) + 1; | |
| } else { | |
| nextIndex = 0; | |
| endOfList = true; | |
| } | |
| /* | |
| Sets the next index. | |
| */ | |
| nextSong = config.songs[nextIndex]; | |
| } | |
| } |
And mannual function my our:
function getNextSong() {
if(typeof Amplitude == 'undefined') return;
let config = Amplitude.getConfig();
if (config.repeat_song) {
/*
If the playlist is shuffled, get the now playing index.
*/
if (config.shuffle_on) {
nextIndex = config.shuffle_list[config.active_index].index;
nextSong = config.shuffle_list[nextIndex];
} else {
nextIndex = config.active_index;
nextSong = config.songs[nextIndex];
}
} else {
/*
If the shuffle is on, we use the shuffled list of
songs to determine our next song.
*/
if (config.shuffle_on) {
/*
If the active shuffle index + 1 is less than the length, then
we use the next shuffle otherwise we go to the beginning
of the shuffle list.
*/
if (parseInt(config.active_index) + 1 < config.shuffle_list.length) {
/*
Set the next index to be the index of the song in the shuffle list.
*/
nextIndex = parseInt(config.active_index) + 1;
} else {
nextIndex = 0;
endOfList = true;
}
nextSong = config.shuffle_list[nextIndex];
} else {
/*
If the active index + 1 is less than the length of the songs, then
we use the next song otherwise we go to the beginning of the
song list.
*/
if (parseInt(config.active_index) + 1 < config.songs.length) {
nextIndex = parseInt(config.active_index) + 1;
} else {
nextIndex = 0;
endOfList = true;
}
/*
Sets the next index.
*/
nextSong = config.songs[nextIndex];
}
}
return nextSong;
}AmplitudeJS Version
5.3.2
Browser Information
No response
Link To Where Your Issue Can Be Reproduced
No response
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bug: Needs Confirmation 🧐Bugs that are reported, but needs to be confirmed and replicated.Bugs that are reported, but needs to be confirmed and replicated.