vlc html js方法,javascript - Embedding VLC plugin on HTML page - Stack Overflow

I found this piece of code somewhere in the web.

Maybe it helps you and I give you an update so far I accomodated it for the same purpose... Maybe I don't.... who the futt knows... with all the nogodders and dobedders in here :-/

function runVLC(target, stream)

{

var support=true

var addr='rtsp://' + window.location.hostname + stream

if ($.browser.msie){

$(target).html('

"VideoLAN.VLCPlugin.2"' + 'classid = "clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"' +

'events = "true"' + 'id = "vlc">

')

}

else if ($.browser.mozilla || $.browser.webkit){

$(target).html('

'pluginspage="http://www.videolan.org"' + 'version="VideoLAN.VLCPlugin.2" ' +

'width="660" height="372"' +

'id="vlc"' + 'autoplay="true"' + 'allowfullscreen="false"' + 'windowless="true"' +

'mute="false"' + 'loop="true"' + '

'branding="false"' + 'controls="false"' + 'aspectRatio="16:9"' +

'target="whatever.mp4">

')

}

else{

support=false

$(target).empty().html('

Error: browser not supported!
')

}

if (support){

var vlc = document.getElementById('vlc')

if (vlc){

var opt = new Array(':network-caching=300')

try{

var id = vlc.playlist.add(addr, '', opt)

vlc.playlist.playItem(id)

}

catch (e){

$(target).empty().html('

Error: ' + e + '
URL: ' + addr +

'

')

}

}

}

}

/* $(target + ' object').css({'width': '100%', 'height': '100%'}) */

Greets

Gee

I reduce the whole crap now to:

function runvlc(){

var target=$('body')

var error=$('#dialog_error')

var support=true

var addr='rtsp://../html/media/video/TESTCARD.MP4'

if (navigator.userAgent.toLowerCase().indexOf("msie")!=-1){

target.append('

VideoLAN.VLCPlugin.2"' + 'classid = "clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"' +

'events = "true"' + 'id = "vlc">

')

}

else if (navigator.userAgent.toLowerCase().indexOf("msie")==-1){

target.append('

'pluginspage="http://www.videolan.org"' + 'version="VideoLAN.VLCPlugin.2" ' +

'width="660" height="372"' +

'id="vlc"' + 'autoplay="true"' + 'allowfullscreen="false"' + 'windowless="true"' +

'mute="false"' + 'loop="true"' + '

'branding="false"' +

'controls="false"' + 'aspectRatio="16:9"' + 'target="whatever.mp4">

')

}

else{

support=false

error.empty().html('Error: browser not supported!')

error.show()

if (support){

var vlc=document.getElementById('vlc')

if (vlc){

var options=new Array(':network-caching=300') /* set additional vlc--options */

try{ /* error handling */

var id = vlc.playlist.add(addr,'',options)

vlc.playlist.playItem(id)

}

catch (e){

error.empty().html('Error: ' + e + '
URL: ' + addr + '')

error.show()

}

}

}

}

};

Didn't get it to work in ie as well...

2b continued...

Greets

Gee

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值