用javascript重新启动html视频 [英] restart html video with javascript

查看:38
本文介绍了用javascript重新启动html视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的html代码中有一个标记,其中包含本地存储的视频(不是youtube的链接).我知道有一种方法可以使用 .pause() .play()从javascript播放/暂停视频.假设我有一个按钮想要重置视频(跳到开始).在javascript/jquery中有针对该功能的功能吗?如果没有,我该如何实现?

I have a tag in my html code with a locally stored video in it (not a link from youtube). I know there is a way to play/pause the video from javascript by using .pause() and .play(). Lets say I have a button that I would like to reset the video (skip to beginning). Is there a function for that in javascript/ jquery? If not then how can I achieve this?

谢谢大家.

推荐答案

您可以使用 currentTime 属性如下

You can use currentTime property as follow

var vid = document.getElementById("myVideo");
vid.currentTime = 0;

这篇关于用javascript重新启动html视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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