YouTube播放器iframe API:playVideo在Firefox 9.0.1上不起作用 [英] YouTube player iframe API: playVideo doesn't work on Firefox 9.0.1

查看:427
本文介绍了YouTube播放器iframe API:playVideo在Firefox 9.0.1上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些YouTube嵌入代码(我只会粘贴导致麻烦的代码,并删除不公开的代码):

 的console.log(YouTube播放器); 
ytplayer.playVideo();

Chrome和FF上的Console.log使用正确的方法向我显示了很好的对象,方法playVideo()在那里存在。它适用于我检查的所有其他浏览器,但它不适用于FF!更有趣的是,当我使用普通的YouTube播放按钮播放视频时,则可以使用pauseVideo()方法(以及所有其他方法:搜索,控制音量),但是我无法使用playVideo()方法...



我使用新的方式嵌入视频:

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

当然,我准备好了在控制台输出中。我不知道我在做什么错,为什么只有FF不工作...有没有JS错误,并没有线索...希望有人有这个问题,并得到它解决!:)

解决方案

我遇到了一个非常类似的问题,正在努力解答。我打电话播放视频()似乎并没有工作。



原始:

 <$点击(功能(){
$('#video')。show();
if(player)
{$ b $如果(typeof player.playVideo =='function')
{
player.playVideo();
}
}

问题是玩家还没有找到 - 如果我给了它一些时间来显示,那么调用工作b
$ b $ $ $ $'code $('#play_movie')。click(function(){
$('#video')。show();
if(player)
{
var fn = function(){player.playVideo();}
setTimeout(fn,1000);
}

不知道这是不是你确切的问题,但我希望它可以帮助别人


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

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!:)

解决方案

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

这篇关于YouTube播放器iframe API:playVideo在Firefox 9.0.1上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆