Detecting Pepper (PPAPI) Flash with Javascript

后端 未结 5 1283
悲&欢浪女
悲&欢浪女 2021-02-10 21:14

We are using a proprietary document viewer which doesn\'t play terribly nice with the Pepper version of Flash found in some flavors of Chrome, so I\'d like to be able to detect

5条回答
  •  难免孤独
    2021-02-10 22:16

    I couldn't get the other examples to work, but the following code works for me on both Mac and PC with Chrome PPAPI enabled or disabled. Also works correctly on other browsers.

    function checkForPepper() {
      return navigator.plugins && _.any(navigator.plugins, function(plugin) {
        return plugin.filename === 'pepflashplayer.dll' || plugin.filename === 'PepperFlashPlayer.plugin';
      });
    }
    alert ('Pepper enabled: '+ checkForPepper());
    

    Note: Requires underscore.js. Fiddle here.

提交回复
热议问题