开发者

How do I detect if quicktime is installed with javascript?

开发者 https://www.devze.com 2023-04-13 02:06 出处:网络
I want to play a sound notification, so I used the method described here: Cross-platform, cross-browser way to play sound from Javascr开发者_如何学运维ipt? However, when quicktime is not installed on

I want to play a sound notification, so I used the method described here: Cross-platform, cross-browser way to play sound from Javascr开发者_如何学运维ipt? However, when quicktime is not installed on the client machine, everytime the soundPlay function is called, a windows popup shows up. It says that quicktime is not installed, and proposes to install it.

For user experience, I would like not to bother users without quicktime like this:

function hasQuickTime() {
  // how do I know ?
}

// play sound only if quickTime is installed
if (hasQuickTime()) {
  soundPlay();
}


See Apple's JavaScript Scripting Guide: Detecting QuickTime with JavaScript

var haveqt = false;

if (navigator.plugins) {
    for (i=0; i < navigator.plugins.length; i++ ) {
        if (navigator.plugins[i].name.indexOf
        ("QuickTime") >= 0)
        { haveqt = true; }
    }
}

if ((navigator.appVersion.indexOf("Mac") > 0)
    && (navigator.appName.substring(0,9) == "Microsoft")
    && (parseInt(navigator.appVersion) < 5) )
{ haveqt = true; }

You can test the variable haveqt for the presence of QuickTime.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号