HTML5视频暂停和快退 [英] HTML5 Video pause and rewind

查看:394
本文介绍了HTML5视频暂停和快退的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法暂停和回放到HTML5视频?或者只是简单地停止?

Is there any way to pause and rewind to 0s a HTML5 video? Or just simply stop?

我有一个jQuery弹出窗口,所以当有人点击它时,弹出窗口显示并播放视频,当你点击关闭按钮时视频暂停。所以我想要做的是,如果你再次点击按钮显示弹出视频开始于开始位置(0秒)。

I got a jQuery popup, so when someone clicks on it, the popup shows up and the video plays, and when you hit the close button the video pauses. So what I'm trying to do is that if you click again the button to show the popup the video begins in the start position (0 secs).

谢谢。

推荐答案

您可以在打开jquery视频元素(或关闭弹出窗口)时获取对它的引用,并使用pause()暂停它,然后将currentTime属性设置为0以返回到开头。

You can get a reference to your jquery video element upon opening it (or closing the popup) and pause it using pause(), and then set the "currentTime" property to 0 to go back to the beginning.

这是对文档

这是一个代码示例:

var mediaElement = document.getElementById("video"); 
mediaElement.pause(); 
mediaElement.currentTime = 0;

这篇关于HTML5视频暂停和快退的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆