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

后端 未结 4 1823
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 18:16

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(ytplayer);
yt         


        
4条回答
  •  甜味超标
    2021-02-15 18:47

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

    ORIGINAL:

    $('#play_movie').click(function(){
        $('#video').show();
        if(player)
        {
            if(typeof player.playVideo == 'function')
            {
                player.playVideo();
            }
        }
    

    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

    $('#play_movie').click(function(){
        $('#video').show();
        if(player)
        {
            var fn = function(){ player.playVideo(); }
            setTimeout(fn, 1000);
        }
    

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

提交回复
热议问题