如何在HTML5中更改视频的播放速度? [英] How to change the playing speed of videos in HTML5?

查看:2713
本文介绍了如何在HTML5中更改视频的播放速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何改变HTML5中的视频播放速度?我已经在w3school中检查过视频标签的属性,但无法接近。任何帮助都会值得赞赏的! 根据本站,这在 playbackRate defaultPlaybackRate 属性,可通过DOM访问。示例:

  / *播放视频两倍* / 
document.querySelector('video')。defaultPlaybackRate = 2.0;
document.querySelector('video')。play();

/ *现在播放的速度只是它的三倍* /
document.querySelector('video')。playbackRate = 3.0;

上面的代码适用于Chrome,也适用于 Firefox 20及以上版本


How to change the video play speed in HTML5? I've checked video tag's attributes in w3school but couldn't approach that.Any help would be appreciated!

解决方案

According to this site, this is supported in the playbackRate and defaultPlaybackRate attributes, accessible via the DOM. Example:

  /* play video twice as fast */
  document.querySelector('video').defaultPlaybackRate = 2.0;
  document.querySelector('video').play();

  /* now play three times as fast just for the heck of it */
  document.querySelector('video').playbackRate = 3.0;

The above works on Chrome, and also Firefox 20 and above.

这篇关于如何在HTML5中更改视频的播放速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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