如何制作改变视频播放状态的按钮?
How to make a button that changes video's playstate?
我想做一个笑话网站和我的朋友们rickroll,但我只能做一个静音自动播放的视频。所以我想制作一个假的cookie同意按钮来改变视频播放状态(基本上是一个播放视频的按钮)
function videoPlay() {
var video = document.getElementById('myvideo');
var btn = document.getElementById('playBtn');
if (video.paused) {
video.play();
btn.innerHTML = "Pause"
} else {
video.pause();
btn.innerHTML = "Play"
}
}
<video id="myvideo" src="https://www.w3schools.com/html/mov_bbb.mp4"></video>
<button id="playBtn" onclick="videoPlay()">Play</button>
我想做一个笑话网站和我的朋友们rickroll,但我只能做一个静音自动播放的视频。所以我想制作一个假的cookie同意按钮来改变视频播放状态(基本上是一个播放视频的按钮)
function videoPlay() {
var video = document.getElementById('myvideo');
var btn = document.getElementById('playBtn');
if (video.paused) {
video.play();
btn.innerHTML = "Pause"
} else {
video.pause();
btn.innerHTML = "Play"
}
}
<video id="myvideo" src="https://www.w3schools.com/html/mov_bbb.mp4"></video>
<button id="playBtn" onclick="videoPlay()">Play</button>