我正在尝试通过放置按钮为iframe制作控制器:播放,暂停。但我无法理解为什么我每次都会失败。我使用的是javascript但无法理解原因:这是我的代码:
<!DOCTYPE html>
<html>
<body>
<button onclick="playVid()" type="button">Play Video</button>
<button onclick="pauseVid()" type="button">Pause Video</button><br>
<iframe id="myVideo" width="100%" height="419" src="small.mp4" frameborder="0" allowfullscreen></iframe>
<script>
var vid = document.getElementById("myVideo");
function playVid() {
vid.play();
}
function pauseVid() {
vid.pause();
}
</script>
<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
</body>
</html>
我也看过帖子: Pausing YouTube iFrame API in JavaScript
Stop all playing iframe videos on click a link javascript
例如但失败......