Sorry if this looks like a repost of an earlier problem of mine, but it isn't. It's a different problem of a different approach.
I've got this iframe:
<iframe id="video1" width="970" height="546" src="https://youtube.com/embed/9IYRC7g2ICg?enablejsapi=1&autoplay=1&controls=0&loop=1&playlist=9IYRC7g2ICg&showinfo=0&modestbranding=0" frameborder="0" allowfullscreen></iframe>
Now to manually pause the video when clicked on a custom button, this works fine:
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#button1').click(function() {
$('#video1')[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
});
});
</script>
pauseVideo is a command listed here https://developers.google.com/youtube/iframe_api_reference.
My question is: i'm somehow completely unable to use commands that expect arguments, for example seekTo(seconds:Number, allowSeekAhead:Boolean)
.
For jumping to 0:20 in the video, I tried:
$('#video1')[0].contentWindow.postMessage('{"event":"command","func":"seekTo","args":"20, true"}', '*');
but with no success. I'm probably putting the arguments in the wrong place, since this is the first time I'm working with the postMessage function for iframes and I kinda feel a bit newbie-like in that sense.
Could anybody help me? :)