Get and set the current progress of HTML5 video

Source: Internet
Author: User

Last week translated an article: How to get the duration of a HTML5 video. Obviously this is a simple but practical technology, but I think there is a more important point of knowledge is to control the video time settings. Setting (setting) and acquiring (getting) time are useful when working with HTML5 technology, so let's take a look at how to achieve this goal!

When it comes to managing video status, it's important to understand currentTime what a ghost is. You can use this property to get to which point in time you are currently playing:

// https://www.youtube.com/watch?v=Cwkej79U3ekconsole.log(video.currentTime);  // 25.431747

currentTimeBoth getter and setter properties, so you can set the currentTime value directly to control the playback progress:

video.currentTime = 0; // Restart

API interfaces are easy to understand and self-explanatory (self-explanatory). You still need to deal with "second" to specify the time, including the actual and external display (both inward and outward), but seconds (second) This unit is as fair as you expect, so this API design is very ingenious.

Examples can refer to the Xiaomi Air Purifier Demo page: http://www.mi.com/air/

<video id="videoIntro" class="video"     data-video-name="intro"     poster="http://c1.mifile.cn/f/i/2014/cn/goods/air/overall/video-main-poster.jpg"    style="height: 600px; width: 800px; display: none;">        <source type="video/mp4"     src="http://c1.mifile.cn/f/i/2014/cn/goods/air/overall/video-intro.mp4?2014120901">        <source type="video/webm"    src="http://c1.mifile.cn/f/i/2014/cn/goods/air/overall/video-intro.webm?2014120901"></video>

In addition, the Apple website demo also uses this kind of control mode.

Original link: http://davidwalsh.name/html5-video-current-time

Original date: March 16, 2015

Translation Date: March 21, 2015

Translators: Anchor Http://blog.csdn.net/renfufei

Get and set the current progress of HTML5 video

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.