Karol Karol - 1 year ago 198
Javascript Question

YouTube player iframe API: playVideo doesn't work on Firefox 9.0.1

I've got some YouTube embedding code (I will paste only code which is causing the trouble for me and cut things which are not public):


Console.log on Chrome and on FF shows me good objects with correct methods, and method playVideo() exists there. And it works for all other browsers I checked, but it doesn't work on FF!? What is even more interesting, that when I play video using normal YouTube play button then I can use pauseVideo() method (and all the others: seeking, controlling volume), but I can't use playVideo() method...

I use new way of embedding video:

ytplayer = new YT.Player(player, {
height: height,
width: width,
videoId: videoid,
allowfullscreen: 'true',
playerVars: {
controls: 0,
showinfo: 0,
wmode: 'opaque',
autoplay: (autoplay ? 1 : 0)
events: {
'onReady': function () {
console.log('I am ready');

Of course 'I am ready' is in console output. I have no idea what I do wrong and why only FF is not working... There is no JS error, and no clue... Hope someone had this problem before and got it resolved!:)

Answer Source

I was having a very similar issue and was struggling with an answer. My calls to playVideo() didn't seem to work.


        if(typeof player.playVideo == 'function')

The issue was that the player was not yet available - if I just gave it a bit of time to show up, then the call worked

        var fn = function(){ player.playVideo(); }
        setTimeout(fn, 1000);

Don't know if this is your exact issue, but I hope it helps someone