Playback speed control for YouTube videos? HTML5?

前端 未结 3 1980
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-23 04:35

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 (

相关标签:
3条回答
  • 2021-01-23 05:01

    http://mediaelementjs.com/ is crossbrowser,uses flash or html5 depending on the browser support and has all the methods you are looking for.

    0 讨论(0)
  • 2021-01-23 05:03

    $('#video').playbackRate = 3.0 or $('video').playbackRate = 3.0 depending on version

    0 讨论(0)
  • 2021-01-23 05:24

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

    iframe api reference: Setting the playback rate

    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.

    Also:

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

    Example code:

    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 :)
          },
        }
      });
    }
    
    0 讨论(0)
提交回复
热议问题