这变得非常令人沮丧。我制作了一个视频并愿意在 js [没有 jquery] 中播放它。而且每次都失败了。控制台说play is not defined
。你能帮我吗
<video id='video'>
<source src='http://techslides.com/demos/sample-videos/small.mp4' type='video/mp4'>
<source src='http://techslides.com/demos/sample-videos/small.ogv' type='video/ogg'>
<embed src='http://techslides.com/demos/sample-videos/small.flv' type='x-shockwave-flash'>
</video>
<button onclick='play()' >Play/Pause</button>
.
window.onload = function() {
var video = document.getElementById('video');
if (video.paused) {
video.play();
} else {
video.pause();
}
};
- 谢谢