浏览器安装vlc插件播放rtsp流

15 篇文章 0 订阅

http://blog.csdn.net/xiaoliouc/article/details/8664081

网上很多例子都不管用了,今天自己参照

 http://jeremiah.blog.51cto.com/539865/161433/

写了一个,经测试通过。注意的是,安装vlc的时候记得勾选ie插件、火狐插件。

 

[html]  view plain copy print ?
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  2. <html xmlns="http://www.w3.org/1999/xhtml" >   
  3. <head>   
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />   
  5. <script>   
  6. var itemId = 0;   
  7. function getVLC(name)   
  8. {   
  9.         if (window.document[name])      
  10.         {   
  11.                 return window.document[name];   
  12.         }   
  13.         if (navigator.appName.indexOf("Microsoft Internet")==-1)   
  14.         {   
  15.                 if (document.embeds && document.embeds[name])   
  16.                         return document.embeds[name];      
  17.         }   
  18.         else   
  19.         {   
  20.                 return document.getElementById(name);   
  21.         }   
  22. }   
  23.   
  24. function doGo(mrl)   
  25. {   
  26.         var vlc = getVLC("vlc");   
  27.         itemId=vlc.playlist.add(mrl);   
  28.         vlc.playlist.playItem(itemId);   
  29.         document.getElementById("btn_stop").disabled = false;   
  30. }   
  31.   
  32. function updateVolume(deltaVol)   
  33. {   
  34.         var vlc = getVLC("vlc");   
  35.         vlc.audio.volume += deltaVol;   
  36. }   
  37.   
  38. function doPlay()   
  39. {   
  40.         vlc.playlist.playItem(itemId);   
  41.            
  42.         document.getElementById("btn_stop").disabled = false;   
  43.         document.getElementById("btn_play").disabled = true;   
  44. }   
  45.   
  46. function doStop()   
  47. {   
  48.         getVLC("vlc").playlist.stop();   
  49.         document.getElementById("btn_stop").disabled = true;   
  50.         document.getElementById("btn_play").disabled = false;   
  51. }   
  52. </script>   
  53. </head>   
  54. <body>   
  55. <div style="margin: 50px">   
  56.         <a title="rtsp://192.168.1.16:554/sample_100kbit.mp4" href="#" onclick="doGo(this.title);return false;">本机的mp4文件</a>   
  57.         <span style="margin: 20px;" />   
  58.         <a title="rtsp://192.168.1.6:8086?h264&amr" href="#" onclick="doGo(this.title);return false;">实时视频流</a>   
  59.         <span style="margin: 20px;" />   
  60. </div>   
  61. <div>   
  62.         <OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" id="vlc"  
  63.     codebase="http://download.videolan.org/pub/videolan/vlc/0.8.6c/win32/axvlc.cab"  
  64.        width="600" height="480" id="vlc" events="True">  
  65.  <param name="MRL" value="" />  
  66.  <param name="Src" value="" />  
  67.    <param name="ShowDisplay" value="True" />  
  68.  <param name="AutoLoop" value="False" />  
  69.  <param name="AutoPlay" value="False" />  
  70.  <param name="Time" value="True"/>  
  71.  <EMBED pluginspage="http://www.videolan.org"  
  72.        type="application/x-vlc-plugin"  
  73.        version="VideoLAN.VLCPlugin.2"  
  74.        width="600"  
  75.        height="480"      
  76.        text="Waiting for video"  
  77.        name="vlc"  
  78.        ></EMBED>  
  79.  </OBJECT>   
  80. </div>   
  81. <div>   
  82. <input type=button id="btn_play" value=" 播放 " onClick='doPlay();' disabled="true">   
  83. <input type=button id="btn_stop" value="停止" onClick='doStop();' disabled="true">   
  84. <input type=button value="静音切换" onclick='getVLC("vlc").audio.togglemute();'>   
  85. <input type=button value="减小音量" onclick='updateVolume(-10)'>   
  86. <input type=button value="增加音量" onclick='updateVolume(+10)'>   
  87. </div>   
  88. </body>   
  89. </html>  


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值