在网页中控制wmplayer播放器

详细参数可查询MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay/mmp_sdk/settingsobject.asp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link href="style/style.css" rel="stylesheet" type="text/css">

<script language="JavaScript">
var state;

//初始化
function playerinit()
{
 player.url="mp3.m3u";
 player.settings.autoStart = false ;
}

//播放
function play()
{
 if (player.controls.isavailable('play'))
 {
  player.controls.play();
  state=setInterval("updatetime()",1000);
  playerinfo.innerHTML = "播放";
 }
}

//暂停
function pause()
{
 if (player.controls.isavailable('pause'))
 {
  player.controls.pause();
  clearInterval(state);
  playerinfo.innerHTML = "暂停";
 }
}

//停止
function stop()
{
 if (player.controls.isavailable('stop'))
 {
  player.controls.stop();
  clearInterval(state);
  playerinfo.innerHTML = "停止";
 }
}

//前首
function previous()
{
 if (player.controls.isavailable( 'previous' ))
 {
  player.controls.previous();
  playerinfo.innerHTML = "前一首";
 }
}

//后首
function next()
{
 if (player.controls.isavailable( 'next' ))
 {
  player.controls.next();
  playerinfo.innerHTML = "下一首";
 }
}

//?
function step()
{
 if (player.controls.isavailable( 'step' ))
 player.controls.step( 1 );
}

//音量-
function voldown()
{
 if ( player.settings.volume < 5 )
 {
  player.settings.volume = 0;
  playerinfo.innerHTML = "0";
 }
 else
 {
  player.settings.volume -= 5;
  playerinfo.innerHTML = player.settings.volume;
 }
}

//音量+
function volup()
{
 if ( player.settings.volume > 95 )
 {
  player.settings.volume = 100;
  playerinfo.innerHTML = "100";
 }
 else
 {
  player.settings.volume += 5;
  playerinfo.innerHTML = player.settings.volume;
 }
}

//静音
function mute()
{
 player.settings.mute = !player.settings.mute;
}

//声道
function balance()
{
 switch (player.settings.balance)
 {
  case 0:
   player.settings.balance = 100;
   playerinfo.innerHTML = '左声道';
   break;
  case 100:
   player.settings.balance = -100;
   playerinfo.innerHTML = '右声道';
   break;
  case -100:
   player.settings.balance = 0;
   playerinfo.innerHTML = '全声道';
   break;
  default :
   player.settings.balance = 0;
   playerinfo.innerHTML = '全声道';
   break;
 }
}

//更新时间
function updatetime()
{
 playerinfo.innerHTML = player.controls.currentPositionString + " | " + player.currentMedia.durationString;
}

</script>
</head>
<body onload="playerinit();">
<table width="300">
  <tr>
    <td><object id="player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" width="300" height="60">
      <param name="autoStart" value="false">
      <param name="balance" value="0">
      <param name="currentPosition" value="0">
      <param name="currentMarker" value="0">
      <param name="enableContextMenu" value="true">
      <param name="enableErrorDialogs" value="false">
      <param name="enabled" value="true">
      <param name="fullScreen" value="false">
      <param name="invokeURLs" value="false">
      <param name="mute" value="true">
      <param name="playCount" value="1">
      <param name="rate" value="1">
      <param name="uiMode" value="none">
      <param name="volume" value="100">
    </object></td>
  </tr>
  <tr>
    <td><span id="playerinfo"></span></td>
  </tr>
  <tr>
    <td>
      <div align="center">
<input type="button" class="but11" onmouseover=this.className="but12"; onmouseout=this.className="but11"; name="previous" title="上一首" onclick="previous();">
<input type="button" class="but21" onmouseover=this.className="but22"; onmouseout=this.className="but21"; name="play" title="播放" onclick="play();">
<input type="button" class="but31" onmouseover=this.className="but32"; onmouseout=this.className="but31"; name="pause" title="暂停" onclick="pause();">
<input type="button" class="but41" onmouseover=this.className="but42"; onmouseout=this.className="but41"; name="stop" title="停止" onclick="stop();">
<input type="button" class="but51" onmouseover=this.className="but52"; onmouseout=this.className="but51"; name="next" title="下一首" onclick="next();">
<input type="button" class="but61" onmouseover=this.className="but62"; onmouseout=this.className="but61"; name="voldown" title="音量-" onclick="voldown();">
<input type="button" class="but61" onmouseover=this.className="but62"; onmouseout=this.className="but61"; name="volup" title="音量+" onclick="volup();">
<input type="button" class="but61" onmouseover=this.className="but62"; onmouseout=this.className="but61"; name="mute" title="静音" onclick="mute();">
<input type="button" class="but61" onmouseover=this.className="but62"; onmouseout=this.className="but61"; name="balance" title="声道" onclick="balance();">
   </div>
 </td>
  </tr>
</table>
<script language = "JavaScript"  for = player event = playstatechange(newstate)>
switch (newstate){
  case 1:
   playerinfo.innerHTML = "停止";
   break;
  case 2:
   playerinfo.innerHTML = "暂停";
   break;
  case 3:
   playerinfo.innerHTML = "正在播放";
   break;
  case 4:
   playerinfo.innerHTML = "4";
   break;
  case 5:
   playerinfo.innerHTML = "5";
   break;
  case 6:
   playerinfo.innerHTML = "正在缓冲...";
   break;
  case 7:
   playerinfo.innerHTML = "7";
   break;
  case 8:
   playerinfo.innerHTML = "8";
   break;
  case 9:
   playerinfo.innerHTML = "正在连接...";
   break;
  case 10:
   playerinfo.innerHTML = "准备就绪。欢迎光临<a href='http://www.knowsky.com'>http://www.knowsky.com</a>";
   break;
  case 11:
   playerinfo.innerHTML = "11";
   break;
  default:
   playerinfo.innerHTML = "";
}
</script>

</body>
</html>

(0)

相关推荐

  • 网页中Flash播放器常用参数设置

    我们现在大部分人做网页,都是直接用DW插入flash,而且DW也是所见即所得,直接生成了相应的flash显示代码.可是我们又有多少人了解这些直接由DW生成的代码呢?其实我接触flash player标签,是在刚学习html的时候,那时书中插入flash只有最简单的<embed src="" width="" height=""></embed>一句,而且在很长一段时间里,只要网页中插入flash我也都是这样写的,当时认为,

  • 网页播放器Object使用详解

    一.代码 复制代码 代码如下: <object ID="javademo" CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" HEIGHT="280" WIDTH="200"> <param name="AUTOSTART" value="0"> <param name="SHUFFLE&qu

  • 在线播放器代码大全

    1.avi格式 <object id="video" width="400" height="200" border="0" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"><param name="ShowDisplay" value="0"><param name="

  • 页面嵌入Windows Media Player播放器代码需要注意的

    这里是WMP的版本ClassID,从WMP7后ID就成了clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6,之前的6.4为clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95,但是之前的版本还是可以用的,只不过新功能用不了罢了. 下面这个是具体的版本号,你可以对比一下你现在的是什么版本. 版本号              Windows Media Player (WMP) 的版本-------------------------

  • 网页播放器的参数含义 Windows Media Player 网页播放器 参数含义

    (默认0为否,-1或1为是)<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="MediaPlayer1" width="286" height="225">   <param name="AudioStream" value="-1">   <param name="A

  • (jsp/html)网页上嵌入播放器(常用播放器代码整理)

    这个其实很简单,只要在HTML上添加以上代码就OK了,前提是你的电脑上已经安装了播放器,如RealPlay. 复制代码 代码如下: <embed src="C:/mp3/10.19/画心.mp3" width="480" height="100"02. loop="false" autostart="false"> </embed> 还有更多的的播放器和设置可供选择: 页面插入REA

  • 网上比较常用的嵌入网页中的播放器代码收藏

    例如:网络上最流行的windows media流(asf,wma,wmv格式...),Real流(rm,rmvb...),还有MPEG系列编码格式(MP4/MP3格式...) Windows Media Video 是微软推出的一种流媒体格式,它是在"同门"的ASF(Advanced Stream Format)格式升级延伸来得.在同等视频质量下,WMV格式的体积非常小,因此很适合在网上播放和传输.Windows Media Player9兼容所有格式的WMV,官方编码器是Window

  • 网页视频播放器程序代码(通用代码)

    '*********************************************** '函数名:SelPlay '作  用:在网页中播放视频 '参  数:strUrl ---- 视频地址            strWidth ---显示视频宽            strHeight ---显示视频高 '*********************************************** Sub SelPlay(strUrl,strWidth,StrHeight) Dim

  • 在线FLV播放器实现方法

    程序代码 复制代码 代码如下: <object type="application/x-shockwave-flash" width="400" height="220"  wmode="transparent" data="flvplayer.swf"> <param name="movie" value="flvplayer.swf" />

  • flvplayer.swf flv视频播放器使用方法

    一.直接在html文件中加载: 复制代码 代码如下: <div id="FlashFile"> <object type="application/x-shockwave-flash" width="470px" height="403px" data="flvplayer.swf?file=movies/company.flv"> <param name="movi

  • WMV网页播放器参数中文详解

    复制代码 代码如下: <object id="mePlay" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,5,0803" standby="Loading Windows Media Pl

  • MediaPlayer 在线播放器代码

    <object id="MediaPlayer1" width="220" height="176" align="baseline" border="0" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> <param name="AudioStream" VALUE="-1&qu

随机推荐