fix: bad redirection, double buttons, double reload

This commit is contained in:
Mylloon 2022-11-21 22:21:36 +01:00
parent c4cf5f3306
commit 4801f8add0
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -60,8 +60,9 @@ const main = () => {
*/
const removeButtons = (parentOfButtons) => {
const buttons = parentOfButtons.getElementsByTagName("button");
for (let index = 0; index < buttons.length; index++) {
parentOfButtons.removeChild(buttons[index]);
console.log(buttons);
while (buttons.length) {
parentOfButtons.removeChild(buttons[0]);
}
};
@ -79,6 +80,10 @@ const updateVideo = (videoFolder, videosList, tree, source, videoId) => {
source.src = `${videoFolder}/${videosList[videoId][0]}.${videosList[videoId][1]}`;
source.type = `video/${videosList[videoId][1]}`;
// Force the reload of the video
// TODO(enhancement): Keep previous volume
videoElement.load();
// Add buttons at the end of the video
videoElement.addEventListener(
"ended",
@ -123,8 +128,4 @@ const updateVideo = (videoFolder, videosList, tree, source, videoId) => {
},
{ once: true }
);
// Force the reload of the video
// TODO(enhancement): Keep previous volume
videoElement.load();
};