1

I embedded a youtube video in a website and want to change the speed of this video. I know that it is possible to change speed in HTML5 videos (cf How to change the playing speed of videos in HTML5?). The problem is that Youtube videos are embedded as an iframe.

I found this code jsfiddle.net/jpreynat/e11oy0eu/ but it only works on desktops and not with mobile devices.

Is there a possibility to change the Youtube video speed on every device?

Community
  • 1
  • 1
Mboe5000
  • 53
  • 1
  • 7
  • I tried code from http://jsfiddle.net/jpreynat/e11oy0eu/ But the Youtube player API only works for desktops. Additionaly I tried to get the video player from the Youtube iframe and to change the speed via the player properties. This was not possible due to cross-site-scripting: ' ' – Mboe5000 Jan 10 '17 at 08:43

1 Answers1

5

Try using postMessage on iframe to pass setPlaybackRate command with rate in argument

var playbackRate = 2;
var data = {event: 'command', func: 'setPlaybackRate', args: [playbackRate, true]};
var message = JSON.stringify(data);
$('#iframe1')[0].contentWindow.postMessage(message, '*');
Viney
  • 6,629
  • 3
  • 21
  • 40