* add possible enhancement
* white text at the end, following recent dark theme change
This commit is contained in:
parent
7a1430aa13
commit
c4cf5f3306
1 changed files with 10 additions and 7 deletions
17
js/main.js
17
js/main.js
|
@ -36,7 +36,9 @@ const main = () => {
|
|||
|
||||
// Add property to the player
|
||||
currentVideo = document.createElement("video");
|
||||
// TODO(enhancement): Custom controls?
|
||||
currentVideo.controls = true;
|
||||
// TODO(enhancement): Better fit window
|
||||
currentVideo.width = window.innerWidth - window.innerWidth / 2;
|
||||
currentVideo.style = "display: block; margin: auto;";
|
||||
|
||||
|
@ -69,20 +71,20 @@ const removeButtons = (parentOfButtons) => {
|
|||
* @param {{number: string[]}} videosList List of videos filenames
|
||||
* @param {{int: int[]}} tree List of all the videos from videosList with the next possibles choices from the video
|
||||
* @param {HTMLSourceElement} source Current video
|
||||
* @param {number} newVideoId Video ID to add to the main element
|
||||
* @param {number} videoId Video ID to add to the main element
|
||||
*/
|
||||
const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => {
|
||||
const updateVideo = (videoFolder, videosList, tree, source, videoId) => {
|
||||
const videoElement = source.parentElement;
|
||||
const mainElement = videoElement.parentElement;
|
||||
source.src = `${videoFolder}/${videosList[newVideoId][0]}.${videosList[newVideoId][1]}`;
|
||||
source.type = `video/${videosList[newVideoId][1]}`;
|
||||
source.src = `${videoFolder}/${videosList[videoId][0]}.${videosList[videoId][1]}`;
|
||||
source.type = `video/${videosList[videoId][1]}`;
|
||||
|
||||
// Add buttons at the end of the video
|
||||
videoElement.addEventListener(
|
||||
"ended",
|
||||
() => {
|
||||
if (tree[newVideoId]) {
|
||||
tree[newVideoId].forEach((nextVideoId, counter) => {
|
||||
if (tree[videoId]) {
|
||||
tree[videoId].forEach((nextVideoId, counter) => {
|
||||
const button = document.createElement("button");
|
||||
|
||||
// TODO(enhancement): Add custom label for the button redirection
|
||||
|
@ -114,7 +116,7 @@ const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => {
|
|||
} else {
|
||||
removeButtons(mainElement);
|
||||
const endText = document.createElement("h1");
|
||||
endText.style = "font-size: 11vh;";
|
||||
endText.style = "font-size: 11vh; color: white;";
|
||||
endText.innerText = "Merci d'avoir regardé !";
|
||||
mainElement.appendChild(endText);
|
||||
}
|
||||
|
@ -123,5 +125,6 @@ const updateVideo = (videoFolder, videosList, tree, source, newVideoId) => {
|
|||
);
|
||||
|
||||
// Force the reload of the video
|
||||
// TODO(enhancement): Keep previous volume
|
||||
videoElement.load();
|
||||
};
|
||||
|
|
Reference in a new issue