在网页中控制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 相关文章推荐
javascript之typeof、instanceof操作符使用探讨
May 19 Javascript
jquery实现左右滑动菜单效果代码
Aug 27 Javascript
JavaScript判断用户名和密码不能为空的实现代码
May 16 Javascript
深入理解js数组的sort排序
May 28 Javascript
jQuery实现鼠标经过购物车出现下拉框代码(推荐)
Jul 21 Javascript
bootstrap fileinput 上传插件的基础使用
Feb 17 Javascript
JavaScript实现前端分页控件
Apr 19 Javascript
jQuery条件分页 代替离线查询(附代码)
Aug 17 jQuery
JS实现的简单标签点击切换功能示例
Sep 21 Javascript
使用Angular-CLI构建NPM包的方法
Sep 07 Javascript
jQuery.parseJSON()函数详解
Feb 28 jQuery
vue pages 多入口项目 + chainWebpack 全局引用缩写说明
Sep 21 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 获取完整url地址
2008/12/20 PHP
关于session在PHP5的配置文件中的详细设置参数说明
2011/04/20 PHP
使用迭代器 遍历文件信息的详解
2013/06/08 PHP
解析php中反射的应用
2013/06/18 PHP
PHP加密解密类实例分析
2015/04/20 PHP
PHP-FPM之Chroot执行环境详解
2015/08/03 PHP
JS 判断undefined的实现代码
2009/11/26 Javascript
jquery动态加载图片数据练习代码
2011/08/04 Javascript
JS实现根据当前文字选择返回被选中的文字
2014/05/21 Javascript
easyui tree带checkbox实现单选的简单实例
2016/11/07 Javascript
AngulerJS学习之按需动态加载文件
2017/02/13 Javascript
js获取元素的偏移量offset简单方法(必看)
2017/07/05 Javascript
基于vue-simplemde实现图片拖拽、粘贴功能
2018/04/12 Javascript
深入理解JavaScript 中的匿名函数((function() {})();)与变量的作用域
2018/08/28 Javascript
swiper在angularjs中使用循环轮播失效的解决方法
2018/09/27 Javascript
vuex管理状态 刷新页面保持不被清空的解决方案
2019/11/11 Javascript
JavaScript ES6 Class类实现原理详解
2020/05/08 Javascript
JavaScript 类的封装操作示例详解
2020/05/16 Javascript
vue实现简单加法计算器
2020/10/22 Javascript
jQuery实现tab栏切换效果
2020/12/22 jQuery
[01:10]DOTA2次级职业联赛 - U5战队宣传片
2014/12/01 DOTA
[37:35]DOTA2上海特级锦标赛A组资格赛#1 Secret VS MVP.Phx第二局
2016/02/25 DOTA
Python实现简单的文件传输与MySQL备份的脚本分享
2016/01/03 Python
Python中的条件判断语句与循环语句用法小结
2016/03/21 Python
python web框架学习笔记
2016/05/03 Python
python按照多个条件排序的方法
2019/02/08 Python
python远程邮件控制电脑升级版
2019/05/23 Python
Pyspark获取并处理RDD数据代码实例
2020/03/27 Python
用HTML5制作数字时钟的教程
2015/05/11 HTML / CSS
Linux的文件类型
2012/03/07 面试题
买卖协议书范本
2014/04/21 职场文书
货物运输服务质量承诺书
2014/05/29 职场文书
小公司融资,商业计划书的8切记
2019/07/15 职场文书
Vue中插槽slot的使用方法与应用场景详析
2021/06/08 Vue.js
redis不能访问本机真实ip地址的解决方案
2021/07/07 Redis
MutationObserver在页面水印实现起到的作用详解
2022/07/07 Javascript