简体   繁体   中英

Recognizing users vlc plugin installation?

I use embed vlc plugin for demonstrating rtsp video stream on my web page.

I include it into my page body in this way:

<embed type="application/x-vlc-plugin" name="VLC" autoplay="yes"
loop="no" volume="100" width="800" height="600" target="rtsp://url.to.stream">

But if user hasn't vlc player plugin installed there is no image, and it doesn't offer link to install it. How can I recognize if user has plugin or no (by JavaScript maybe), or maybe it is possible to add more attributes of <embed> element, with which it will offer plugin installation automatically?

One option is to use VLC Media Player Plugin Detector .

http://www.pinlady.net/PluginDetect/VLC/

In most of the cases is works fine but has certain drawbacks you should consider.

You can use the following function:

isVLCInstalled: function() {
    var name = "VLC";
    if (navigator.plugins && (navigator.plugins.length > 0)) {
        for(var i=0;i<navigator.plugins.length;++i) 
            if (navigator.plugins[i].name.indexOf(name) != -1) 
              return true;
    }
    else {
        try {
            new ActiveXObject("VideoLAN.VLCPlugin.2");
            return true;
        } catch (err) {}
    }
    return false;

}

I use this for the first time I access to Vlc object:

// First get Vlc object (using getElementById or jquery $('#vlc') etc.)
// Now you test if Vlc web plugin is available checking a method or a property of Vlc object
try {
    vlc.playlist.stop();
    // Or you can try another method or properties for example vlc.playlist.clear()
} catch (error) {
    console.log("Vlc Web Plugin is not available");
    // Or put your code when Vlc web plugin is not available
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM