在网页中控制wmplayer播放器


Posted in Javascript onJuly 01, 2006

详细参数可查询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>

Javascript 相关文章推荐
JS验证邮箱格式是否正确的代码
Dec 05 Javascript
浅谈JavaScript function函数种类
Dec 29 Javascript
html+javascript+bootstrap实现层级多选框全层全选和多选功能
Mar 09 Javascript
基于JavaScript实现的顺序查找算法示例
Apr 14 Javascript
vue.js中v-on:textInput无法执行事件问题的解决过程
Jul 12 Javascript
IE11下使用canvas.toDataURL报SecurityError错误的解决方法
Nov 19 Javascript
基于jquery的on和click的区别详解
Jan 15 jQuery
微信小程序排坑指南详解
May 23 Javascript
angularJs利用$scope处理升降序的方法
Oct 08 Javascript
vue中的ref和$refs的使用
Nov 22 Javascript
一个Java程序猿眼中的前后端分离以及Vue.js入门(推荐)
Apr 19 Javascript
JavaScript中使用Spread运算符的八种方法总结
Jun 18 Javascript
Javascript的IE和Firefox兼容性汇编
Jul 01 #Javascript
提高代码性能技巧谈—以创建千行表格为例
Jul 01 #Javascript
对textarea框的代码调试,而且功能上使用非常方便,酷
Jun 30 #Javascript
列表内容的选择
Jun 30 #Javascript
会自动逐行上升的文本框
Jun 30 #Javascript
自动检查并替换文本框内的字符
Jun 30 #Javascript
一个很简单的办法实现TD的加亮效果.
Jun 29 #Javascript
You might like
php 无限级分类学习参考之对ecshop无限级分类的解析 带详细注释
2010/03/23 PHP
在WordPress中获取数据库字段内容和添加主题设置菜单
2016/01/11 PHP
php array_pop 删除数组最后一个元素实例
2016/11/02 PHP
Yii 框架使用Forms操作详解
2020/05/18 PHP
提高jQuery性能的十个诀窍
2013/11/14 Javascript
两种方法实现在HTML页面加载完毕后运行某个js
2014/06/16 Javascript
JavaScript中5种调用函数的方法
2015/03/12 Javascript
javascript cookie的基本操作(添加和删除)
2017/07/24 Javascript
angular $watch 一个变量的变化(实例讲解)
2017/08/02 Javascript
jQuery+SpringMVC中的复选框选择与传值实例
2018/01/08 jQuery
vue + webpack如何绕过QQ音乐接口对host的验证详解
2018/07/01 Javascript
原生js实现form表单序列化的方法
2018/08/02 Javascript
JavaScript中set与get方法用法示例
2018/08/15 Javascript
vue动态绑定class的几种常用方式小结
2019/05/21 Javascript
vue.js 打包时出现空白页和路径错误问题及解决方法
2019/06/26 Javascript
jquery多级树形下拉菜单的实例代码
2019/07/09 jQuery
Nodejs在局域网配置https访问的实现方法
2020/10/17 NodeJs
[03:22]DOTA2超级联赛专访单车:找到属于自己的英雄
2013/06/08 DOTA
[01:22:19]EG vs TNC Supermajor小组赛B组败者组第一轮 BO3 第二场 6.2
2018/06/03 DOTA
python使用cPickle模块序列化实例
2014/09/25 Python
python中从str中提取元素到list以及将list转换为str的方法
2018/06/26 Python
python实现基于信息增益的决策树归纳
2018/12/18 Python
pyqt弹出新对话框,以及关闭对话框获取数据的实例
2019/06/18 Python
python opencv捕获摄像头并显示内容的实现
2019/07/11 Python
django model通过字典更新数据实例
2020/04/01 Python
使用python实现下载我们想听的歌曲,速度超快
2020/07/09 Python
JAVA中的关键字有什么特点
2014/03/07 面试题
促销活动方案模板
2014/02/24 职场文书
预备党员的自我评价
2014/03/12 职场文书
经济担保书范文
2014/04/02 职场文书
我的祖国演讲稿
2014/05/04 职场文书
组织生活会发言材料
2014/12/15 职场文书
社交电商模式的兴起:这些新的商机千万别错过
2019/07/26 职场文书
python 下载文件的几种方式分享
2021/04/07 Python
Nginx禁止ip访问或非法域名访问
2022/04/07 Servers
HTML页面点击按钮关闭页面的多种方式
2022/12/24 HTML / CSS