as3 pepperFlash检查运行时

时间:2013-07-02 08:31:48

标签: actionscript-3 flash google-chrome

如何在运行时检查flashPlayer版本的pepperFlash?

我想为pepperflash处理stage3d,对于标准flash播放器版本不同处理

更新

我发现了一个javascript函数,所以如果有人可以帮我用ExternalInterface调用它:

var checkForPepper = function() {
if (navigator.plugins) {
    for (var i=0, count = navigator.plugins.length; i < count; i++) {
        var filename = navigator.plugins[i].filename;
        if (filename === 'pepflashplayer.dll' || filename === 'PepperFlashPlayer.plugin') return true;
    }
}
return false;

2 个答案:

答案 0 :(得分:1)

在AS3中更新您的答案以获得更易读的JS:

    var js:XML = <js>
        <![CDATA[
            function() {
                if (navigator.plugins) {
                    for (var i=0, count = navigator.plugins.length; i < count; i++) {
                        var filename = navigator.plugins[i].filename;
                        if (filename === 'pepflashplayer.dll' || filename === 'PepperFlashPlayer.plugin') 
                            return true;
                    }
                }
                return false;   
            }
        ]]>         
        </js>

        if(ExternalInterface.available)
        {
            var isPepper:Boolean = ExternalInterface.call(js);
            ExternalInterface.call("alert('isPepper = "+isPepper+"')");
        }

答案 1 :(得分:0)

这是如何:

        _hasPepperFlash = String(ExternalInterface.call("function() {if (navigator.plugins) {for (var i = 0, count = navigator.plugins.length; i < count; i++){var filename = navigator.plugins[i].filename; if (filename === 'pepflashplayer.dll' || filename === 'PepperFlashPlayer.plugin') return true; } } return false;} "))

要注意它必须在一条线上,否则它不会起作用。至少在我的IDE IntelliJ