Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2129293
  • 博文数量: 229
  • 博客积分: 7217
  • 博客等级: 上校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 17:23
个人简介

个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club

文章分类

全部博文(229)

文章存档

2017年(1)

2016年(20)

2015年(23)

2013年(1)

2012年(23)

2011年(68)

2010年(62)

2009年(31)

分类: LINUX

2010-02-03 13:30:38

Control vlc play in javascript


<html>
<head><title>Demo of VLC mozilla plugin</title></head>
<body>
<h1 align="center">Demo of Firefox VLC Plugin</h1>

<embed type="application/x-vlc-plugin" pluginspage=""
    version="VideoLAN.VLCPlugin.2" width="100%" height="85%" id="vlc">
</embed>

<script language="Javascript">

    var vlc=document.getElementById("vlc");
    var id=vlc.playlist.add("rtsp://192.168.1.18:8554/crazystone.ts");
    vlc.playlist.playItem(id);
    var seek_time = 1000 * 50;
    var volume_number = 10;

   function volume_up()
   {
        alert("Before up is " + vlc.audio.volume);
       if((vlc.audio.volume + volume_number) <= 200)
        {
            vlc.audio.volume += volume_number;    
        }
        else
        {
            vlc.audio.volume = 200;    
        }
        alert("After up is " + vlc.audio.volume);    
   }
   
   function volume_down()
   {
        alert("Before down is " + vlc.audio.volume);        
        if((vlc.audio.volume - volume_number)>= 0)
        {
            vlc.audio.volume -= volume_number;        
        }
        else
        {
            vlc.audio.volume = 0;
        }
        alert("After down is " + vlc.audio.volume);
   }
   
   function onPause()
   {
        vlc.playlist.togglePause();
   }
   
   function onStop()
   {
        vlc.playlist.stop();
   }
    
    function onPlay()
    {
        vlc.input.rate = 1.0
    }
   
    function onFullscreen()
    {
        vlc.video.toggleFullscreen();    
    }
   
    function onMute()
    {
        vlc.audio.toggleMute();    
    }
   
    function onSeek_forward()
    {            
        if((vlc.input.time + seek_time) < vlc.input.length )
        {
            vlc.input.time = vlc.input.time + seek_time;    
        }    
        else
        {
            vlc.input.time = 0;        
        }
    }
   
    function onSeek_backward()
    {
        if((vlc.input.time - seek_time)>= 0)
        {
            vlc.input.time -= seek_time;        
        }
        else
        {
            vlc.input.time = 0        
        }
    }
    
    function fastForward()
    {
        vlc.input.rate = 8.0    
    }
   
   function backForward()
   {
        vlc.input.rate = 0.5
   }
   
</script>


<br />
  <a href="javascript:;" onclick='onPlay()'>Play</a>
  <a href="javascript:;" onclick='onPause()'>Pause</a>
  <a href="javascript:;" onclick='onStop()'>Stop</a>
  <a href="javascript:;" onclick='onFullscreen()'>Fullscreen</a>
  <a href="javascript:;" onclick="volume_up()">Volume_Up</a>
  <a href="javascript:;" onclick="volume_down()">Volume_Down</a>
  <a href="javascript:;" onclick="onMute()">Mute</a>
  <a href="javascript:;" onclick="onSeek_forward()">Seek_forward</a>
  <a href="javascript:;" onclick="onSeek_backward()">Seek_backward</a>
  <a href="javascript:;" onclick="fastForward()">FastForward</a>
  <a href="javascript:;" onclick="backForward()">BackForward</a>
  
</body>
</html>


References:
1、
http://wiki.videolan.org/Documentation:WebPlugin#Build_HTML_pages_that_use_the_plugin_.28VLC_version_up_to_0.8.5.29
2、

阅读(3082) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~