(建站指南)精彩转贴区(12) HIDDEN="TRUE"//隐藏方式 AUTOSTART="TRUE"//自动播放 LOOP="TRUE"//循环播放 NAME="MySound"//嵌入对象名 < /EMBED> 2. JavaScript的音频支持函数 通过JavaScript的音频支持函数您可以控制任何一个嵌入在主页中的音频控制台。 JavaScript提供了如下的支持函数: play({loop[TRUE,FALSEoranINT]},′{url-to-sound}′)//播放 pause()//暂停 stop()//停止播放当前文件 StopAll()//停止播放所有文件 start-time({numberofseconds})//从第几秒开始 end-time({numberofseconds})//到第几秒结束 setvol({percentagenumber-without"%"sign})//音量百分比控制 fade-to({volumepercentyouwishtofadeto-withoutthe"%"sign})//削减音量到 fade-from-to({volumepercentstartfade},{volumepercentendfade})//从某个音量值削减到某个音量值 start-at-beginning()//从文件头开始 stop-at-end()//到文件尾停止 下面四个是状态测试函数 IsReady()//准备状态测试 IsPlaying()//播放状态测试 IsPaused()//暂停状态测试 GetVolume()//获取当前音量值 3. 应用举例 下面是一个包含NetscapeNavigator3.0音频播放器所有五个元素的例子。考虑到有些用户没有声卡,本例中没有设置自动播放。读者可以根据自己的喜好结合鼠标事件将各个元素和测试函数都添加到图形按钮中。程序清单如下: < HTML> < HEAD> < TITLE>自编音频播放器演示< /TITLE> < SCRIPTLANGUAGE=JavaScript> < !--Writer:YuHaiHe functionplaySound(){ document.firstSound.play(true); } functionpauseSound(){ document.firstSound.pause(); } functionstopSound(){ document.firstSound.stop(); } functionvolup(){ currentVolume=document.firstSound.GetVolume(); newVolume=(currentVolume+10); if(document.firstSound.GetVolume()==100){ alert("音量已经达到最大值"); } if(newVolume<101){ document.firstSound.setvol(newVolume); } else { if((newVolume<=100)&&(newVolume>90)){ document.firstSound.setvol(100); } } } functionvoldown(){ currentVolume=document.firstSound.GetVolume(); newvolume=(currentVolume-10); if(document.firstSound.GetVolume()==0){ alert("音量已经达到最小值"); } if(newVolume>0){ document.firstSound.setvol(newVolume); } else { if((newVolume>=0)&&(newVolume<10)){ document.firstSound.setvol(0); } } }