vlc的网页播放

来源:互联网 发布:大数据正确理解 编辑:程序博客网 时间:2024/05/17 04:14

使用的浏览器为IE11,firebox 48.0.2  和 google chrome  版本 50.0.2661.87 m

1.首先看源代码


<html><head><meta charset=UTF-8" /><script>var itemId = 0;function getVLC(name){        if (window.document[name])            {                return window.document[name];        }       /* if (navigator.appName.indexOf("Microsoft Internet") == -1)//indexOf(“Netscape“) 是返回浏览器名称字符串中“Netscape“的位置,如果找不到,则返回-1.此处没有作用,因为navigator.appName()返回的都是Netscape        {alert("if");                if (document.embeds && document.embeds[name])//ie没有这些属性                        return document.embeds[name];            }*/        else        {                return document.getElementById(name);        }}function doGo(mrl){        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;}</script></head><body><div style="margin: 50px">        <a title="she.mp3" href="#" onclick="doGo(this.title);return false;">01.ts</a>        <span style="margin: 20px;" />        <a title="1.flv" href="#" onclick="doGo(this.title);return false;">02.mp3</a>        <span style="margin: 20px;" /></div><div>        <object classid="clsid:9be31822-fdad-461b-ad51-be1d1c159921"                width="640"                height="480"                id="vlc"                events="true">        <param name="mrl" value="" />        <param name="showdisplay" value="true" />        <param name="autoloop" value="false" />        <param name="autoplay" value="false" />        <param name="volume" value="50" />        <param name="starttime" value="0" />        <embed pluginspage="http://www.videolan.org"                     type="application/x-vlc-plugin"                     version="videolan.vlcplugin.2"                     width="640"                     height="480"                     name="vlc">        </embed>        </object></div><div><input type=button id="btn_play" value=" 播放 " onClick='doPlay();' disabled="true"><input type=button id="btn_stop" value="停止" onClick='doStop();' disabled="true"><input type=button value="静音切换" onclick='getVLC("vlc").audio.togglemute();'><input type=button value="减小音量" onclick='updateVolume(-10)'><input type=button value="增加音量" onclick='updateVolume(+10)'></div></body></html>

2.其中google chrome 不支持vlc(暂时不知何故)

3.嵌入式的object和embed还不太明白



0 0
原创粉丝点击