更改视频时如何释放内存?

时间:2019-06-07 15:51:05

标签: javascript

当源改变时,如何释放用于存储视频的内存:

var video = document.querySelector('.video');
var nextButton = document.getElementById('next-button');
nextButton.addEventListener('click', function() {
    video.src = videoQueue.shift();
});

1 个答案:

答案 0 :(得分:0)

var video = document.querySelector('.video');
var nextButton = document.getElementById('next-button');
nextButton.addEventListener('click', function() {
    video.removeAttribute("src");//This will clear memory
    video.load();//Refresh
});

我希望这会有所帮助。