i have Constanta In Javascript , i want to replace This Value Before Initialitate this conts but not working , i have idea to replacing Const With Other Const but This not Working again
const audioMap = [
"<?php echo base_url('sounds/Airport_Bell.mp3');?>",
"<?php echo base_url('sounds/C.wav'); ?>"
];
self.queue.shift();
document.getElementById("list_antrian").innerHTML = JSON.stringify(self.queue);
let audio = new Audio();
function playSequence(sounds) {
const playNextSounds = (sounds) => {
if (sounds.length > 0) {
var audio = new Audio();
audio.src = sounds[0];
audio.currentTime = 0;
audio.play();
sounds.shift();
audio.addEventListener('ended', function () {
return playNextSounds(sounds);
})
} else {
self._call();
}
}
let currentSoundIndex = 0;
if (sounds.length > 0) {
const audio = new Audio();
audio.src = sounds[0];
audio.currentTime = 0;
audio.play();
sounds.shift();
audio.addEventListener('ended', function () {
return playNextSounds(sounds);
})
} else {
self._call();
}
}
playSequence([
"<?php echo base_url('sounds/A.wav'); ?>",
"<?php echo base_url('sounds/B.wav'); ?>",
"<?php echo base_url('sounds/C.wav'); ?>"
]);
I want Change playSequence With audioMap
Thanks
use let when mutating, const when it's constant.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const
You can merge those array's together, like in the following, if you're trying to just bring in audioMap and the array currently being passed into playSequence
const audioMap = [
"<?php echo base_url('sounds/Airport_Bell.mp3');?>",
"<?php echo base_url('sounds/C.wav'); ?>"
];
const audioSet = [
"<?php echo base_url('sounds/A.wav'); ?>",
"<?php echo base_url('sounds/B.wav'); ?>",
"<?php echo base_url('sounds/C.wav'); ?>"
]
playSequence([...audioSet, ...audioMap]);
You can also mutate the array, but I recommend the approach above.