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元素属性而已!
javascript速度