YouTube视频的播放速度控制? HTML5? [英] Playback speed control for YouTube videos? HTML5?

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

问题描述

我需要为youtube视频实现一个视频播放速度控制器(例如:以1/2速度播放视频),我认为HTML5是目前唯一可行的方法(如果可能的话)。我对HTML5视频知之甚少,但我对youtube js API了解很多。谁能指出我正确的方向?如果解决方案只适用于某些浏览器,那也没关系。

I need to implement a video playback speed controller (e.g.: play the video at 1/2 speed) for youtube videos, and I'm thinking that HTML5 is currently the only way to do this (if it's even possible). I know very little about HTML5 video, but I know a lot about the youtube js API. Can anyone point me in the right direction? It's okay if the solution will only work in some browsers.

推荐答案

新的iframe api允许您控制视频的速度:

The new iframe api allows you to control the speed of the video:

iframe api reference:设置播放率


默认播放率为1,表示视频正常播放。播放率可能包括0.25,0.5,1,1.5和2等值。

The default playback rate is 1, which indicates that the video is playing at normal speed. Playback rates may include values like 0.25, 0.5, 1, 1.5, and 2.

此外:


调用此函数并不能保证回放率实际发生变化。

Calling this function does not guarantee that the playback rate will actually change.

示例代码:

function onYouTubeIframeAPIReady() {
  var player;
  player = new YT.Player('player', {
    videoId: 'M7lc1UVf-VE',
    playerVars: { 'autoplay': 1, 'controls': 0 },
    events: {
      'onReady': function(e){
        // e.target = player
        e.target.setPlaybackRate(0.5); // set to half speed
        e.target.playVideo(); // watch lolcats in slow motion :)
      },
    }
  });
}

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

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