2
<!doctype html>
<html>
<head>
<title>Tag video</title>
<meta charset="utf-8" />
<script language="Javascript">
window.onload = function(){
var b1 = document.getElementById("src1");
var b2 = document.getElementById("src2");
var b3 = document.getElementById("src3");
var b4 = document.getElementById("src4");
b1.addEventListener("click",changeSrc);
b2.addEventListener("click",changeSrc);
b3.addEventListener("click",changeSrc);
b4.addEventListener("click",changeSrc);
}
function changeSrc(event){
console.log(event);
console.log(event.target.value);
var video = document.getElementById("Video1");
video.src = event.target.value;
}
function vidplay1()
{
var video = document.getElementById("Video1");
var button = document.getElementById("play");
if (video.paused)
{
video.play();
button.textContent = "II";
}
else
{
video.pause();
button.textContent = "➤";
}
}
function restart1()
{
var video = document.getElementById("Video1");
video.currentTime = 0;
}
function skip1(value)
{
var video = document.getElementById("Video1");
video.currentTime += value;
}
function expand1()
{
//2do;
}
</script>
</head>
<body>
<table align="center">
<tr>
<td>
<video controls width="502" height="360" id="Video1">
<source src="video1.webm" type=video/webm>
</video>
</td>
</tr>
<tr>
<td align="center">
<div id="PLAYER1">
<button id="restart" onclick="restart1()">↺</button>
<button id="rew" onclick="skip1(-10)">↶</button>
<button id="play" onclick="vidplay1()">➤</button>
<button id="fastFwd" onclick="skip1(10)">↷</button>
<button id="exp" onclick="expand1()">[x]</button>
</div>
</td>
<button id="src1" value = "video1.webm"><img src="video1.png" width="310" height="220" /></button>
<button id="src2" value = "video2.webm"><img src="video2.png" width="310" height="220" /></button>
<button id="src3" value = "video3.webm"><img src="video3.png" width="310" height="220" /></button>
<button id="src4" value = "video4.webm"><img src="video4.png" width="300" height="220" /></button>
</tr>
</table>
</body>
<html>
Sorry for the ignorance, but if I take this code you sent me and put in place of my function expand1 was to work my button, or I have to make changes?
– Lawrence
The toggle function toggles between enabling and disabling the full screen. If you wish you can paste the function elsewhere and just call it within expand1.
– Samir Braga
I’m a beginner in javascript and didn’t understand how to implement the code to make my button work with onclick
– Lawrence
I switched the expand1 button by toggleFullScreen and took the expand1 function.
– Lawrence
@Lawrence will edit the answer as clearly as possible, now I’m by cell phone.
– Samir Braga
I took a closer look at your answer and I was able to apply it to my code.
– Lawrence