firefox vlc插件_html 嵌入vlc插件

这篇博客介绍了如何在HTML中嵌入VLC播放器插件,包括针对Firefox和IE的兼容性处理。通过JavaScript函数如`doGo1`、`doStop`和`updateVolume`来控制播放、停止和音量调整。同时,提供了检测浏览器是否安装VLC插件的函数,未安装时引导用户下载。
摘要由CSDN通过智能技术生成

/*

加载本地html文件

// System.IO.FileInfo file = new System.IO.FileInfo("wmh.html");

//this.webBrowser1.Url = new Uri(file.FullName);

//webBrowser1.DocumentCompleted += webBrowser1DocumentCompleted; //加载地图完成时调用

//if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "wmh.html"))

//{

this.webBrowser1.Url = new Uri(wmh.html);

}

this.webBrowser1.ObjectForScripting = this;

*/

var itemId = 0;

function init()

{

if( navigator.appName.indexOf("Microsoft Internet") == -1 )

{

onVLCPluginReady()

}

else if( document.readyState == ‘complete’ )

{

onVLCPluginReady();

}

else

{

/* Explorer loads plugins asynchronously */

document.onreadystatechange = function()

{

if( document.readyState == ‘complete’ )

{

onVLCPluginReady();

}

}

}

}

function getVLC(name)

{

if (window.document[name])

{

return window.document[name];

}

if (navigator.appName.indexOf("Microsoft Internet")==-1)

{

if (document.embeds && document.embeds[name])

return document.embeds[name];

}

else

{

return document.getElementById(name);

}

}

function doItemCount()

{

var vlc = getVLC("vlc");

if( vlc )

{

var count = vlc.playlist.items.count;

//document.getElementById("itemCount").value = " Items: " + count + " ";

}

}

//这里是播放的函数 可以从c#里面调

/*

private void Form1_Shown(object sender, EventArgs e)

{

//    if (checkBrowser())//输入参数

//    {

//string targetURL = textBox1.Text;

doGo1(targetURL);

//    }

}

public void doGo1(string targetURL)//

{

webBrowser1.Document.InvokeScript("doGo1", new string[] { targetURL });

}

*/

function doGo1(targetURL)

{

var vlc = getVLC("vlc");

//targetURL = "rtsp://202.104.126.35/demo";

if( vlc )

{

vlc.playlist.items.clear();

var options = [":rtsp-tcp"];

var itemId = vlc.playlist.add(targetURL,"",options);

//var itemId = vlc.playlist.add("rtsp://202.104.126.35/demo");

if( itemId != -1 )

{

// play MRL

vlc.playlist.playItem(itemId);

}

else

{

alert("cannot play at the moment !");

}

doItemCount();

//document.getElementById("btn_stop").disabled = false;

}

}

function RtspDelete()

{

var vlc = getVLC("vlc");

vlc.playlist.items.clear();

}

function doAdd(targetURL)

{

var vlc = getVLC("vlc");

var options = [":vout-filter=deinterlace", ":deinterlace-mode=linear"];

if( vlc )

{

vlc.playlist.items.clear();

var itemId=vlc.playlist.add(targetURL);

//vlc.playlist.add(targetURL, "", options);

if( itemId != -1 )

{

// play MRL

vlc.playlist.playItem(itemId);

}

doItemCount();

}

}

/*

function doGo(mrl)

{

mrl = "rtsp://202.104.126.35/demo";

var vlc = getVLC("vlc");

itemId=vlc.playlist.add(mrl);

vlc.playlist.playItem(itemId);

document.getElementById("btn_stop").disabled = false;

}

*/

function updateVolume(deltaVol)

{

var vlc = getVLC("vlc");

vlc.audio.volume += deltaVol;

}

function doPlay()

{

vlc.playlist.playItem(itemId);

document.getElementById("btn_stop").disabled = false;

document.getElementById("btn_play").disabled = true;

}

function doStop()

{

getVLC("vlc").playlist.stop();

document.getElementById("btn_stop").disabled = true;

document.getElementById("btn_play").disabled = false;

}

//仅适用于IE浏览器是,并且安装有vlc插件,则返回true;

function isInsalledIEVLC()

{

var vlcObj = null;

var vlcInstalled= false;

try {

vlcObj = new ActiveXObject("VideoLAN.Vlcplugin.1");

if( vlcObj != null )

{

vlcInstalled = true

}

} catch (e)

{

vlcInstalled= false;

}

return vlcInstalled;

}

//仅适用于firefox浏览器是,并且安装有vlc插件,则返回true;

function isInsalledFFVLC()

{

var numPlugins=navigator.plugins.length;

for  (i=0;i

{

plugin=navigator.plugins[i];

if(plugin.name.indexOf("VideoLAN") > -1 || plugin.name.indexOf("VLC") > -1)

{

return true;

}

}

return false;

}

这里是浏览器检测是不是安装了vlc,没有安装就马上安装个

/* 浏览器检测 */

function checkBrowser()

{

var browser=navigator.appName

var b_version=navigator.appVersion

var version=parseFloat(b_version)

if ( browser=="Netscape"  && version>=4)

{

if(isInsalledFFVLC())

{

alert("已装VLC");

}

else

{

alert("未装VLC");

location.href="http://download.videolan.org/pub/videolan/vlc/2.2.1/win32/vlc-2.2.1-win32.exe";

//location.href=“http://rj.baidu.com/soft/detail/12124.html?ald”;

}

}else if(browser=="Microsoft Internet Explorer" && version>=4)

{

if(isInsalledIEVLC())

{

alert("已装VLC");

}else

{

alert("未装VLC,请先安装");

location.href="http://download.videolan.org/pub/videolan/vlc/2.2.1/win32/vlc-2.2.1-win32.exe";

//location.href=“http://rj.baidu.com/soft/detail/12124.html?ald";

}

}

}

这里是调用本地vlc播放器的插件这里十分重要

http://zzck-dental.com" οnclick="doGo(this.title);return false;">本机的mp4文件 –>

   –>

codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"

width="1140" height="520" id="vlc" events="True">

type="application/x-vlc-plugin"

version="VideoLAN.VLCPlugin.2"

width="600"

height="480"

text="Waiting for video"

name="vlc"

>

本文由【waitig】发表在等英博客 本文固定链接:html 嵌入vlc插件 欢迎关注本站官方公众号,每日都有干货分享!

点赞 (0)赏分享 (0)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值