flash 播放控制代码

本文介绍了一个用于控制Flash播放的HTML页面脚本实现。该脚本提供了多种控制功能,包括播放、暂停、停止、快进、快退等,并且能够显示当前播放帧数和总帧数。此外,还实现了加载进度条以及按钮状态更新等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 <HTML>
<HEAD> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>Flash播放</title>
<script >
var movie,timer,step,total,state=null,delay=100
function init()
{
movie=window.document.movie
total=movie.TotalFrames
step=total/100|0
buttonState(false)
timer=setInterval("showStatus()",delay)
window.setTimeout("Play();",2000)
}
function Rewind(){
movie.Rewind()
}

function Back(){
if(movie.FrameNum!=0&&state!="forward"){
state="back"
Quick()
setTimeout("Back()",delay)
}
else state=null
}
function Play(){
movie.Play();
}
function Pause(){ 
with(movie)IsPlaying()?StopPlay():Play()
}
function Stop(){
movie.StopPlay()
}
function Forward(){
if(movie.FrameNum!=total-1&&state!="back"){
state="forward"
Quick()
setTimeout("Forward()",delay)
}
else state=null
}
function GoToEnd(){
movie.GoToFrame(total-1)  
}
function Replay(){
Rewind()
Play()
setTimeout("Play()",delay*5)
}
function showStatus(){
var N=movie.FrameNum+1
bar.style.width=Math.round(N*100/total)+"%"
frameCount.innerText="下载完成,如未播放请点击下方或Flash中的播放按钮进行播放 当前播放帧数: " +N+"/"+total
}
function Quick(){
var targetFrame=movie.FrameNum+step*{back:-1,forward:1}[state] 
movie.GoToFrame(targetFrame)
}
function selectMovie(){
document.getElementById("moviefile").click()
}
function buttonState(de){
var buttons=ctlButtons.document.all.tags("BUTTON")
for(var i=0;i<buttons.length-1;i++)
buttons[i].disabled=de
}
function loaded(){
var movie=document.getElementById("movie")
if(movie.PercentLoaded()==100)
init()
else setTimeout("loaded()",delay)
bar.style.width=movie.PercentLoaded()+"%"
frameCount.innerText=" 请稍候...正在下载:"+bar.style.width

}
</script>
<style>
button{font:normal 12px Tahoma;color:#333333;}
button{border:1px solid #333333;background:#EEEEEE;margin:2px;font-family:Webdings;height:20px}
</style>

<base href="" target="_blank">
</HEAD>
<BODY background="" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<center>
<object id="movie" name="movie" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="800" height="600">
        <param name="movie" value="http://www.pconline.com.cn/pcedu/carton/xc/10306/flash/030620epsi.swf">
        <param name="quality" value="high">
        <param name="wmode" value="transparent">
        <embed src="http://www.pconline.com.cn/pcedu/carton/xc/10306/flash/030620epsi.swf" width="800" height="600" quality="high"  type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
      </embed>
</object>

<br>

<div cellspacing="0" cellpadding="0" id="bar" style="width:0%;height:3px;background:#00FF44"></div>
<div  style="text-align:center;" id="frameCount"></div>

<span id="ctlButtons">
<button onClick="Play()" title="播放">4</button>
<button onClick="Pause()" title="暂停">;</button>
<button onClick="Stop()" title="停止"><</button>
<button onClick="Rewind()" title="跳至第一帧">9</button>
<button onClick="Back()" title="快退">7</button>
<button onClick="Forward()" title="快进">8</button>
<button onClick="GoToEnd()" title="跳至最末帧">:</button>
<button onClick="Replay()" title="重放">q</button>
</span>
</center>
<script defer>
buttonState(true)
loaded()
</script>
</BODY>
</HTML>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值