关于mediaplay控件问题

kidd_cen 2002-11-06 07:07:06
javascript怎么捕抓SendPlayStateChangeEvents事件?我想当这个事件发生时执行宁外一段代码。
...全文
120 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
kidd_cen 2002-11-07
  • 打赏
  • 举报
回复
哦,明白了,谢谢
flashsoft2000 2002-11-07
  • 打赏
  • 举报
回复
<SCRIPT FOR="Player" EVENT="PlayStateChange(lOldState, lNewState)" LANGUAGE="JScript">
var playStates=new Array();
playStates[0] = "播放已经停止(mpStopped)"
playStates[1] = "播放暂停(mpPaused )"
playStates[2] = "正在播放(mpPlaying)"
playStates[3] = "正在等待流开始(mpWaiting)"
playStates[4] = "向前搜索(mpScanForward)"
playStates[5] = "向后搜索(mpScanReverse)"
playStates[6] = "向前跳跃(mpSkipForward)"
playStates[7] = "向后跳跃(mpSkipReverse)"
playStates[8] = "流已经关闭(mpClosed)"
document.title=(playStates[lOldState]+"==>"+playStates[lNewState])
</SCRIPT>
kidd_cen 2002-11-07
  • 打赏
  • 举报
回复
为什么不能接受到SendPlayStateChange事件呢?
<OBJECT ID="player" WIDTH="400" HEIGHT="100" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" >
</OBJECT>
<SCRIPT LANGUAGE="JavaScript">
<!--
player.AutoStart=false;
player.Filename="1.mp3";
player.SendPlayStateChangeEvents=true;
function player::SendPlayStateChange(){
alert(player.PlayState); //事件处理代码
}

//player.Play();
//player.SendPlayStateChangeEvents=true;

//-->
</SCRIPT>
kidd_cen 2002-11-07
  • 打赏
  • 举报
回复
先谢过个位,试完一定给分
flashsoft2000 2002-11-07
  • 打赏
  • 举报
回复
还是给你秋水的代码吧

<script language="JScript">
/*========================================
简单播放器的完整控制1.0
Design:FlashSoft2000
2002-8-22
========================================*/
var PlayType=" avi,mpg,mpeg,m1v,mp2,wav.mp3";//定义可播放的类型

function CheckType(){//检测载入的文件类型
var s=FileObj.value.split(".");
return PlayType.indexOf(s[s.length-1].toLowerCase())>0?true:false;
}
function PlayerControl(Action){
if(Action=="change"){//给播放控件赋路径
FileObj.click();
if(FileObj.value!=""&&CheckType()){
Player.filename=FileObj.value;
var ListName=FileObj.value.split("\\");
var ListName=ListName[ListName.length-1].split(".");
var ListName=ListName.slice(0,ListName.length-1);
AddOption(PlayList.length+". "+ListName,FileObj.value);
}
}
if(Action=="play"&&Player.filename!=""){//播放
Player.play();
try{clearInterval(play_time)}catch(e){}
play_time=setInterval("CourseButton.style.pixelLeft=Math.round((CourseButtonBox.offsetWidth-CourseButton.offsetWidth)*Player.currentposition/Player.duration)",10);
}
if(Action=="pause"&&Player.filename!=""){//暂停
Player.pause();
}
if(Action=="stop"){//停止
Player.stop();
Player.currentposition=0;
}
if(Action=="mute"){//静音改变
Player.mute=Player.mute?false:true;
}
}
var EventObject=0,Old_X,New_X;
function button_down(){//拖动按钮按下事件
EventObject=event.srcElement;
Old_X=event.clientX;
EventObject.setCapture();
}
function button_move(){//拖动按钮移动事件
if(EventObject){
New_X=event.clientX;
var MovePels=EventObject.style.pixelLeft+New_X-Old_X;
var MaxBound=document.all(EventObject.id+"Box").offsetWidth-EventObject.offsetWidth;
if(EventObject&&MovePels<=MaxBound&&MovePels>=0){
EventObject.style.pixelLeft=MovePels;
eval(EventObject.id+"Event("+EventObject.style.pixelLeft+","+MaxBound+")");
Old_X=New_X;
}
}
}
function button_up(){//拖动按钮松开事件
if(EventObject){
EventObject.releaseCapture();
EventObject=0;
}
}
function CourseButtonEvent(l,m){//播放进程控制
Player.currentposition=Math.round(Player.duration*l/m);
}
function VolumeButtonEvent(l,m){//音量控制
Player.volume=-Math.round((1-l/m)*100)*19.6;
}
function TrackButtonEvent(l,m){//声道控制
var n=Math.round(l/m*100);
Player.balance=n==50?0:n>50?(n-50)*180:n<50?-(50-n)*180:0;
}
function AddOption(Text,Value){
PlayList.add(new Option(Text,Value),1);
}
function RemoveOption(){
PlayList.remove(PlayList.selectedIndex==-1?0:PlayList.selectedIndex);
}
function window.onload(){
Player.volume=0;
}
</script>

<style>
body,td,a{
font-size:9pt;
}
</style>
<table border>
<tr>
<td>
<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" id="Player" width="427" height="300">
<param name="clicktoplay" value="0">
<param name="showcontrols" value="0">
<param name="enablecontextmenu" value="1">
<param name="autoplay" value="0">
<param name="windowlessvideo" value="1">
</object>
<input type="file" id="FileObj" style="display:none">
<br>
<input type="button" value="选择文件" onclick="PlayerControl('change')"> <input type="button" value="播放" onclick="PlayerControl('play')">
<input type="button" value="暂停" onclick="PlayerControl('pause')"> <input type="button" value="停止" onclick="PlayerControl('stop')">
<input type="button" value="静音" onclick="PlayerControl('mute')">
<br>
播放进程:
<div id="CourseButtonBox" style="height:12;width:427;background:f4f4f4"><input id="CourseButton" type="button" style="position:relative;left:0;height:12;width:20" onmousedown="button_down()" onmousemove="button_move()" onmouseup="button_up()"></div>
调节音量:
<div id="VolumeButtonBox" style="height:12;width:427;background:f4f4f4"><input id="VolumeButton" type="button" style="position:relative;left:367;height:12;width:60" onmousedown="button_down()" onmousemove="button_move()" onmouseup="button_up()"></div>
调节声道:
<div id="TrackButtonBox" style="height:12;width:427;background:f4f4f4"><input id="TrackButton" type="button" style="position:relative;left:208;height:12;width:10" onmousedown="button_down()" onmousemove="button_move()" onmouseup="button_up()"></div>
</td>
<td>
双击播放,右击删除
<br>
<select id="PlayList" size="99999" style="width:200;height:400" ondblclick="Player.filename=options[selectedIndex].value;Player.play()" oncontextmenu="RemoveOption()">
</select>
</td>
</tr>
</table>
<SCRIPT FOR="Player" EVENT="PlayStateChange(lOldState, lNewState)" LANGUAGE="JScript">
var playStates=new Array();
playStates[0] = "播放已经停止(mpStopped)"
playStates[1] = "播放暂停(mpPaused )"
playStates[2] = "正在播放(mpPlaying)"
playStates[3] = "正在等待流开始(mpWaiting)"
playStates[4] = "向前搜索(mpScanForward)"
playStates[5] = "向后搜索(mpScanReverse)"
playStates[6] = "向前跳跃(mpSkipForward)"
playStates[7] = "向后跳跃(mpSkipReverse)"
playStates[8] = "流已经关闭(mpClosed)"
document.title=(playStates[lOldState]+"==>"+playStates[lNewState])
</SCRIPT>
flylyke 2002-11-07
  • 打赏
  • 举报
回复
if(MediaPlayer.SendPlayStateChange)
{
//你想要执行的代码
}
else{
////你想要执行的代码
}
Go_Rush 2002-11-07
  • 打赏
  • 举报
回复
直接写这样一个函数就可以

function MediaPlayer1::SendPlayStateChange(){
//事件处理代码
}
king_xing 2002-11-06
  • 打赏
  • 举报
回复
很简单的嘛:
<SCRIPT LANGUAGE=javascript FOR=MediaPlayer1 EVENT=SendPlayStateChange(参数...)>
<!--
WMPSendPlayStateChange(参数...)
//-->
</SCRIPT>
把上面的加入到包括MediaPlay控件的网页中,参数要对应哦!而且应该放在控件定义后面!WMPSendPlayStateChange()中就加入你要额外执行和代码!
这只是事件响应哦,像该控件的右键菜单替换就比较罗嗦一点!

87,937

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧