javascript速度_使用JavaScript设置视频播放速度

javascript速度

I love that media has moved from custom plugins (Flash…gross) to basic HTML <video> and <audio> elements. Treating these media sources as just another element allows us to use CSS filters to adjust display, for example. The less we need to do with ffmpeg or plugins, the better.

我喜欢媒体已经从自定义插件(Flash ... gross)转移到基本HTML <video><audio>元素。 例如,将这些媒体源视为另一个元素,使我们可以使用CSS过滤器来调整显示。 我们需要对ffmpeg或插件做的越少,越好。

I’ve been noticing that many video sites have implemented a feature to adjust video playback speed, which is awesome if you’re trying to get through some sports highlights faster or to see that monster slam dunk in super slow motion. I was hoping it didn’t require some special type of server to send the file in slower or faster chunks and I was right: all you need is the playbackRate property!

我一直注意到,许多视频网站都实现了调整视频播放速度的功能,如果您试图更快地通过一些体育赛事亮点或者看到超级慢动作灌满怪物灌篮,那真是太棒了。 我希望它不需要某些特殊类型的服务器来以较慢或较快的块发送文件,我是对的:您所需要的只是playbackRate属性!

const video = document.querySelector("video");

// Slow it to 50% speed
video.playbackRate = 0.5;

// Twice as fast!
video.playbackRate = 2;

// Back to normal
video.playbackRate = 1;

Using a number less than 1 slows the video down, a number larger than 1 speeds the video up, and 1 restores the video to normal speed. Also note that playbackRate is not a HTML attribute — it’s a property.

使用小于1的数字会使视频变慢,大于1的数字会使视频变慢,而1会使视频恢复正常速度。 另请注意, playbackRate不是HTML属性,而是一个属性。

Adjusting playback rate isn’t something you’d want to do for all video sites, but if you think your users may like it, it’s only one HTML element property away!

并不是所有视频网站都希望调整回放速率,但是如果您认为用户可能喜欢它,那只是一个HTML元素属性而已!

翻译自: https://davidwalsh.name/video-playback-speed

javascript速度

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值