Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jPlayer:当条件为false时停止_Javascript_Jplayer - Fatal编程技术网

Javascript jPlayer:当条件为false时停止

Javascript jPlayer:当条件为false时停止,javascript,jplayer,Javascript,Jplayer,我正在使用flash检测脚本来确定浏览器上的flash支持。 我希望jPlayer在启用闪存时停止。到目前为止,这似乎不起作用 $(document).ready(function() { if(!FlashDetect.installed){ $("#audioplayer").hide(); }else{ $("#jp_container_1").hide(); $("#startpage_jplayer").jPl

我正在使用flash检测脚本来确定浏览器上的flash支持。 我希望jPlayer在启用闪存时停止。到目前为止,这似乎不起作用

$(document).ready(function() {
    if(!FlashDetect.installed){
        $("#audioplayer").hide();      
    }else{
        $("#jp_container_1").hide();
        $("#startpage_jplayer").jPlayer("mute");
        $("#startpage_jplayer").jPlayer("stop");     
    }
})

提前谢谢你

如果你想一遍又一遍地重复某件事,你需要把它放在一个循环中

if (!FlashDetect.installed)
{
    $("#audioplayer").hide();
}
else 
{
    while(!FlashDetect.installed){ } // This line will happen as long as (!FlashDetect.installed) is true

    // This stuff will happen when (!FlashDetect.installed) is false (Flash is installed)
    $("#jp_container_1").hide();
    $("#startpage_jplayer").jPlayer("mute");
    $("#startpage_jplayer").jPlayer("stop");
}
请注意,我上面的代码可能会导致浏览器停止响应。 但这是循环的基础

相反,一个更好的方法是检查它是否安装在间隔上

这段代码要好得多,它将每隔20秒检查是否安装了flash,如果安装了,那么它将停止jPlayer


您可以阅读

为什么需要不断检查闪存支持?“他不想/不需要不断地检查,我想,他的代码就是不工作,这个答案没有解决我不认为的问题。”MartinMazzaDawson OP对问题的措辞听起来像是他想在jPlayer启动后停止它,这就是为什么我不断地检查它。你需要更具体一些。flashdetect if/else语句是否有效?此外,此代码需要在您初始化jPlayer之后完成,如果没有初始化,那么它们将不会停止jPlayer。显示您的jPlayer代码。我的代码在播放器初始化后运行。这句话很好用!我到办公室后会把密码寄出去。非常感谢。
if (!FlashDetect.installed)
{
    $("#audioplayer").hide();
}
setInterval(function(){
    if (FlashDetect.installed)
    {
        $("#jp_container_1").hide();
        $("#startpage_jplayer").jPlayer("mute");
        $("#startpage_jplayer").jPlayer("stop");

     }
}, 20000);