用javascript 如何控制 media player 7, 急!!!???

jumpding 2002-09-21 11:00:39
要求:能全屏播放,控制音量的开关和大小,开始播放,暂停播放,停止,快进,快退。

有没有现成的代码,不胜感激。
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
meizz 2002-09-21
  • 打赏
  • 举报
回复
function ClickPlay()
{
if (CanPlay)
{
CanPlay=false;
CanPause=true;
CanSetPos=true;
PlayState=1;
if (!CanStop)
{
CanStop=true;
}
DoPlay();
if(flagShowWhat==0) {showMedia();flagShowWhat=1;}
if(Living) {setTimeout('getlen()',100)}
}
}
function ClickPause()
{
if (CanPause)
{ showFlash();
CanPause=false;
CanPlay=true;
PlayState=4
CanSetPos=false;
if(moveon) clearTimeout(mfollow)
DoPlayPause();
flagShowWhat=0;
}
}

function ClickStop()
{
if (CanStop)
{ showFlash();
CanStop=false;
CanPlay=true;
PlayState=0
if (CanPause)
{
CanPause=false;
}
if(CanSetPos) {CanSetPos=false;}
if(moveon) clearTimeout(mfollow)
mblock.style.left=0
DoStop();

}
}

function Total_Up()
{
if(SetPosStart)
setpos();
}
function formattime(second)
{
var t_hour,t_minute,t_second,t_temp;
t_temp=Math.floor(second/60);
t_second=''+Math.floor(second-t_temp*60);
if (t_second.length==1) {t_second='0'+t_second}
t_minute=t_temp;
t_temp=Math.floor(t_temp/60);
t_minute=''+(t_minute-t_temp*60);
if (t_minute.length==1) {t_minute='0'+t_minute}
t_hour=t_temp;
return t_hour+':'+t_minute+':'+t_second;
}

function SetSrc(File)
{
if (CanStop)
ClickStop();

SetSource(File);

if (AutoPlay)
ClickPlay();
}
//-->
</script>
<body leftmargin=0 topmargin=0 bgcolor="#000031" onload="SetSrc('mms://210.83.136.13/110123.wmv?progname=沙顿海');ShowTime();">
<div style="position:absolute;top:0;left:0;width:366;height:367">
<table border=0 cellpadding=0 cellspacing=0>
<tr><td>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td><img src="images/left.gif" border=0 width="7" height="308"></td>
<td bgcolor=black width=352 height=308 valign="top">
<table border=0 cellpadding=0 cellspacing=0>
<tr><td width=352 height=288>
<div id="flashads" style="position:absolute;visibility:visible;z-index:5">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" WIDTH=352 HEIGHT=288>
<PARAM NAME=movie VALUE="ads/flashads.swf"> <PARAM NAME=quality VALUE=high>
<EMBED src="ads/flashads.swf" quality=high WIDTH=352 HEIGHT=288 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>
</div>
<div id="mediaPlayer" style="visibility:visible;z-index:1">
<OBJECT classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" height=288 id=Player width=352 VIEWASTEXT>
<PARAM NAME="URL" VALUE="">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="balance" VALUE="0">
<PARAM NAME="currentPosition" VALUE="0">
<PARAM NAME="defaultFrame" VALUE="">
<PARAM NAME="playCount" VALUE="1">
<PARAM NAME="autoStart" VALUE="false">
<PARAM NAME="currentMarker" VALUE="0">
<PARAM NAME="invokeURLs" VALUE="-1">
<PARAM NAME="baseURL" VALUE="">
<PARAM NAME="volume" VALUE="50">
<PARAM NAME="mute" VALUE="0">
<PARAM NAME="uiMode" VALUE="none">
<PARAM NAME="enabled" VALUE="-1">
<PARAM NAME="enableContextMenu" VALUE="-1">
<PARAM NAME="fullScreen" VALUE="1">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIFilename" VALUE="">
<PARAM NAME="captioningID" VALUE="">
</OBJECT>
</div>
</td>
</tr>
<tr><td width=352 height=20>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td width=150 style="color:#00ff00;padding-left:10"><span id="currentstatus"></span></td>
<td width=202 style="color:#ffffff;padding-right:10" align="right"><span id="face"></span><span id="ttime"></span></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td><img src="images/right.gif" border=0 width="7" height="308"></td>
</tr>
</table>
</td>
<tr><td>
<table border=0 cellpadding=0 cellspacing=0>
<tr><td><img src="images/left1.gif" border=0 width="10" height="59"></td>
<td><a href="#" onClick="ClickPlay()"><img src="images/play.gif" border=0 width="55" height="59" onmouseover="this.src=gplay_on.src" onmouseout="this.src=gplay.src"></a></td>
<td><a href="#" onClick="ClickStop()"><img src="images/stop.gif" border=0 width="35" height="59" onmouseover="this.src=gstop_on.src" onmouseout="this.src=gstop.src"></a></td>
<td><a href="#" onClick="ClickPause()"><img src="images/pause.gif" border=0 width="35" height="59" onmouseover="this.src=gpause_on.src" onmouseout="this.src=gpause.src"></a></td>
<td><a href="#" onClick="SetFullScreen()"><img src="images/fullscreen.gif" border=0 width="40" height="59" onmouseover="this.src=gfullscreen_on.src" onmouseout="this.src=gfullscreen.src"></a></td>
<td background="images/slider.gif" width=180 height=59>
<div id=movie onmousemove=movego() onmouseup=Total_Up() style="height:25;left:0;position:relative;top:0;width:180">
<div id=mblock style="height:25px;left:0;position:absolute;top:0">
<img alt=播放位置 onmousedown=moves() border=0 src="images/knob.gif" style="cursor:hand;" width="14" height="25">
</div>
</div>
</td>
<td><img src="images/right1.gif" border=0 width="11" height="59"></td>
</table>
</td>
</table>
</div>
</body>
</html>
meizz 2002-09-21
  • 打赏
  • 举报
回复

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>vod</title>
<style type="text/css">
body,td {font-size:12px;font-family:helvetica,verdana,sans serif}
</style>
<script language="javascript">
<!--
function preload(imgObj,imgSrc)
{ eval(imgObj+"=new Image()");
eval(imgObj+".src='"+imgSrc+"'");
}

preload("gplay","images/play.gif");
preload("gplay_on","images/play_on.gif");
preload("gstop","images/stop.gif");
preload("gstop_on","images/stop_on.gif");
preload("gpause","images/pause.gif");
preload("gpause_on","images/pause_on.gif");
preload("gfullscreen","images/fullscreen.gif");
preload("gfullscreen_on","images/fullscreen_on.gif");
//-->
</script>
<script language="JavaScript">
<!--
flagShowWhat=1

function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function showMedia()
{ document.all['mediaPlayer'].style.visibility='visible';
document.all['flashads'].style.visibility='hidden';
document.all['mediaPlayer'].style.zIndex=5;
document.all['flashads'].style.zIndex=1;
}

function showFlash()
{ document.all['mediaPlayer'].style.visibility='hidden';
document.all['flashads'].style.visibility='visible';
document.all['mediaPlayer'].style.zIndex=1;
document.all['flashads'].style.zIndex=5;
}
// -->
</script>
<SCRIPT FOR="Player" EVENT="Buffering(bStart)" LANGUAGE="JScript">
if(!bStart)
{ showMedia();
}
else showFlash();
</SCRIPT>
<script for="Player" event="error()" language="JScript">
showMedia();
</script>
</head>
<script language="javascript">
<!--
m=4;
movestep=10;movetime=5;movestop=true;movestart=false;curmenu=-1;leftshow=false;rightshow=false;bothstar=false;var moveobj;var nnnn;
moveon=false;movelen=165;timesnum=100;rmstart=false;rm_tollen=0;timelen=0;volumlen=48;volon=false;ChangeSizeRate=1;balance=0
document.onmouseup=Total_Up
document.ondragstart=doDragStart
function doDragStart() {event.returnValue=false}

var Living=true
var AutoPlay=true
var IsVidio
var HSFileName=''
var LSFileName=''
var Button_Num=0;
var Real
Real='document.Player.controls.'
var CanPlay=true;
var CanStop=true;
var CanPause=true;
var Mute=false;
var CanSetPos=false;
var SetPosStart=false;
var GetLenStart=false
var CanSetVol=true;
var SetVolStart=false
var bigwin=false;
var PlayState=0;//0-无(停止);1-connecting;2-buffuring;3-playing;4-pause
var CurrentEntry=1;

function GetBufferPercent()
{
var rate=Player.network.bufferingprogress;
var percent=rate+'%';
return percent;
}

function ShowTime()
{
var length;
length = Player.currentMedia.durationString;
var nowtime;
nowtime = Player.controls.currentPositionString;
face.innerHTML = nowtime;
ttime.innerHTML = "/"+length;
var tempstatus;
var current_status;
tempstatus=Player.playState;
switch(tempstatus)
{
case 3:
current_status="正在播放";
break;
case 1:
current_status="停止";
break;
case 2:
current_status="暂停中";
break;
case 8:
current_status="播放结束";
break;
case 6:
current_status="缓冲:"+GetBufferPercent();
break;
default:
current_status="检查缓冲";
}
currentstatus.innerHTML = current_status;
timerID = setTimeout("ShowTime()", 1000);
}

function DoPlay()
{
eval(Real+'Play()');
}

function DoStop()
{
eval(Real+'Stop()');
eval(Real+'CurrentPosition=0');
}

function DoPlayPause()
{
eval(Real+'Pause()');
}

function SetPosition(Pos)
{
eval(Real+'CurrentPosition='+Pos);
}

function GetLength()
{
return Player.currentMedia.duration;
}

function GetPosition()
{
tt=eval(Real+'CurrentPosition')
return tt*1000;
}

function SetSource(srcname)
{
Player.URL=srcname;
}

//function SetWH(widthpx,heightpx)
//{
// eval(Real+'width=widthpx')
// eval(Real+'height=heightpx')
//}

function SetFullScreen()
{
Player.fullScreen=true;
}

function moves()
{
if(CanSetPos&&event.button!=2)
{
DoPlayPause()
orix=event.x
orileft=mblock.style.pixelLeft
if(moveon) clearTimeout(mfollow)
SetPosStart=true
}
else
return false
}

function movego()
{
if(SetPosStart)
{
newx=event.x
disx=newx-orix
newleft=orileft+disx
if(newleft>-1&&newleft<movelen) mblock.style.left=newleft
}
}

function setpos()
{
SetPosStart=false
newleft=mblock.style.pixelLeft
rcp=Math.round((newleft/movelen)*rm_tollen/1000)
SetPosition(rcp)
setTimeout('moveshow()',8000)
DoPlay()
}

function getlen()
{
rm_tollen=GetLength()*1000
if(rm_tollen==0) {reget=setTimeout('getlen()',50);GetLenStart=true}
else
{
CanSetPos=true;
if(GetLenStart) clearTimeout(reget)
timelen=Math.floor(rm_tollen/timesnum)
moveshow()
}
}

function moveshow()
{
rm_curpos=GetPosition()
resttime=rm_tollen-rm_curpos
//if (CurrentEntry!=eval('Player.'+'GetCurrentEntry()')) {CurrentEntry=eval('Player.'+'GetCurrentEntry()');
//getlen();
//}
if (eval('Player.'+'playState')==0) {clearTimeout(mfollow);ClickStop()}
else if(rm_curpos<rm_tollen)
{
blockpos=Math.floor((movelen/rm_tollen)*rm_curpos)
mblock.style.left=blockpos
moveon=true
mfollow=setTimeout('moveshow()',1000)
}
}


孟子E章 2002-09-21
  • 打赏
  • 举报
回复
<body>
<OBJECT classid=CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95 codeBase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,05,0809 height=256 id="NSOPlay" type=application/x-oleobject width=245 standby="Connecting with Live Event. Please wait patiently...">
<PARAM NAME="AudioStream" VALUE="-1">
<PARAM NAME="AutoSize" VALUE="0">
<PARAM NAME="AutoStart" VALUE="-1">
<PARAM NAME="AnimationAtStart" VALUE="-1">
<PARAM NAME="AllowScan" VALUE="-1">
<PARAM NAME="AllowChangeDisplaySize" VALUE="-1">
<PARAM NAME="AutoRewind" VALUE="-1">
<PARAM NAME="Balance" VALUE="-1">
<PARAM NAME="BaseURL" VALUE="">
<PARAM NAME="BufferingTime" VALUE="5">
<PARAM NAME="CaptioningID" VALUE="-1">
<PARAM NAME="ClickToPlay" VALUE="-1">
<PARAM NAME="CursorType" VALUE="-1">
<PARAM NAME="CurrentPosition" VALUE="-1">
<PARAM NAME="CurrentMarker" VALUE="-1">
<PARAM NAME="DefaultFrame" VALUE="content">
<PARAM NAME="DisplayBackColor" VALUE="0">
<PARAM NAME="DisplayForeColor" VALUE="16777215">
<PARAM NAME="DisplayMode" VALUE="-1">
<PARAM NAME="DisplaySize" VALUE="-1">
<PARAM NAME="Enabled" VALUE="-1">
<PARAM NAME="EnableContextMenu" VALUE="-1">
<PARAM NAME="EnablePositionControls" VALUE="-1">
<PARAM NAME="EnableFullScreenControls" VALUE="-1">
<PARAM NAME="EnableTracker" VALUE="-1">
<PARAM NAME="Filename" VALUE="http://lucky.myrice.com/play.asx">
<PARAM NAME="InvokeURLs" VALUE="-1">
<PARAM NAME="Language" VALUE="-1">
<PARAM NAME="Mute" VALUE="0">
<PARAM NAME="fullScreen" VALUE="true">
<PARAM NAME="PlayCount" VALUE="-1">
<PARAM NAME="PreviewMode" VALUE="0">
<PARAM NAME="Rate" VALUE="1">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMIFileName" VALUE="">
<PARAM NAME="SelectionStart" VALUE="-1">
<PARAM NAME="SelectionEnd" VALUE="-1">
<PARAM NAME="SendOpenStateChangeEvents" VALUE="-1">
<PARAM NAME="SendWarningEvents" VALUE="-1">
<PARAM NAME="SendErrorEvents" VALUE="-1">
<PARAM NAME="SendKeyboardEvents" VALUE="0">
<PARAM NAME="SendMouseClickEvents" VALUE="-1">
<PARAM NAME="SendMouseMoveEvents" VALUE="-1">
<PARAM NAME="SendPlayStateChangeEvents" VALUE="-1">
<PARAM NAME="ShowCaptioning" VALUE="0">
<PARAM NAME="ShowControls" VALUE="-1">
<PARAM NAME="ShowAudioControls" VALUE="-1">
<PARAM NAME="ShowDisplay" VALUE="-1">
<PARAM NAME="ShowGotoBar" VALUE="0">
<PARAM NAME="ShowPositionControls" VALUE="-1">
<PARAM NAME="ShowStatusBar" VALUE="-1">
<PARAM NAME="ShowTracker" VALUE="-1">
<PARAM NAME="TransparentAtStart" VALUE="-1">
<PARAM NAME="VideoBorderWidth" VALUE="0">
<PARAM NAME="VideoBorderColor" VALUE="0">
<PARAM NAME="VideoBorder3D" VALUE="0">
<PARAM NAME="Volume" VALUE="-450">
<PARAM NAME="WindowlessVideo" VALUE="0">
<EMBED type="video/x-ms-asf-plugin" pluginspage="http://www.microsoft.com/goto/mscom/windows/mediaplayer/default.asp" filename="http://colorweb.go.163.com/play.asx"
name="NSOPlay"
width="286"
height="172"
DefaultFrame="content"
AnimationAtStart="-1"
AutoRewind="-1"
AutoStart="-1"
Autosize="-1"
ControlType="-1"
DisplaySize="6"
ShowAudioControls="-1"
ShowControls="-1"
ShowDisplay="-1"
ShowGotoBar="-1"
ShowPositionControls="-1"
ShowStatusBar="-1"
ShowTracker="-1"
TransparentAtStart="-1">
</EMBED>
</OBJECT>
<br>
<input onclick="document.all.NSOPlay.pause()" type=button value="停止">
<input onclick="document.all.NSOPlay.AutoSize='-1';document.all.NSOPlay.fullScreen='true'" type=button value="fillscreen">
<input onclick="document.all.NSOPlay.Play()" type=button value="播放">
<input onclick="document.all.NSOPlay.ShowStatusBar='0'" type=button value="没有状态栏">
<input onclick="document.all.NSOPlay.Volume='-1000'" type=button value="减小声音">
<input onclick="document.all.NSOPlay.Volume='0'" type=button value="增大声音">
<input onclick="document.all.NSOPlay.Stop();document.all.NSOPlay.CurrentPosition=0;document.all.NSOPlay.play()" type=button value="回放">
<input onclick="document.all.NSOPlay.Previous()" type=button value="上一首">
<input onclick="document.all.NSOPlay.Next()" type=button value="下一首">
<input onclick="document.all.NSOPlay.FastForward()" type=button value="快进"><br>
最后的三个属性对多首曲目才有效果,有的属性只有相应的属性设置了才会起作用。
</body>

87,994

社区成员

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

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