3
I’m making a music player in jQuery/Javascript/HTML5 and it’s going well, but when it starts to run the songs +or- in the 13th track starts to slow down the page and gives a "latch" and it’s impossible to continue without updating the page and losing the playlist, wanted to know what the problem with my current code...
function readFile3(file, file2){
fileA = URL.createObjectURL(file);
audioElement.setAttribute('src', fileA);
audioElement.play();
var test = $("#musics").html();
$(audioElement).on("loadedmetadata", function () {
var test3 = test.replace('<div class="music"><div class="bola"></div>' + file3[file2].name + '</div>', '<div class="music2"><div class="bola2"></div>' + file3[file2].name + '</div>');
$("#musics").html(test3);
$("#div3a").scrollTop(0);
$("#div3a").scrollTop($(".music2").position().top);
});
$(audioElement).on("ended", function () {
if (file2 < fill - 1) {
$("#musics").html(test);
file2 = file2 + 1;
readFile3(file3[file2], file2);
}
else {
$("#musics").html(test);
audioElement.load();
}
});
$(audioElement).on("timeupdate", function () {
tempo();
videoTimeUpdateHandler();
});
};
It’s not my first jQuery script that happens to be a jQuery bug or I’m doing something wrong?
Is that all your code? Have you ever done any Profiling to see which operations consume the most CPU/RAM/Disk access?
– Oralista de Sistemas
@Renan, I did the Profiling on Chrome and I did not reach any conclusion, I had never used this feature...so I left the link with the player! Note: this is not the entire code...
– Alan PS
It may be that it is instantiating several times some object, and leaving there, even after finalized, something like this.
– Tony