0

我在网页上有 html5 视频。但我希望它暂停/播放视频本身,而不是点击音量等视频控件。

提前感谢您的宝贵帮助

4

2 回答 2

1

HTML5 <video> tag does not allow this option by default. However, you can use javascript to control your video (make it react to various events).

Here are few links that deals with these issues:

Try any of the approaches in these arcitcles and it should be easy - and try showing some of your code when asking a question - it will make it easier for us to give you more detailed answer :-)

For example, you can add some onClickEvent to your video or its container and then write js function to stop the video (by accessing it with its id)...

于 2013-07-29T09:33:35.117 回答
0

这是你可以做的

var myVideo = document.getElementById("video1");

/*
 * for playing and pausing the video
 */
function playPause() {
        if (myVideo.paused)
            myVideo.play();
        else
            myVideo.pause();
}

HTML

<button onclick="playPause()">Play/Pause</button>
<video id="video1" width="420">
    <source src="resources/videos/your_video.webm" type="video/webm">
            Your browser does not support HTML5 video.
    </source>
</video>

希望这能解决您的问题。

于 2013-07-29T09:50:47.760 回答