关于声音控制的函数

anny000 2006-04-13 10:03:58
<script language="JavaScript">
<!--
function play()
{
document.sy.play()==true;
}
function stop()
{
document.sy.play()==true;
}
//--> </script>
<embed src="wav/ZIR00002[1].wav" loop=false autostart=false hidden=true width=0 height=0 name=sy></embed>

声音控制这么做有什么错吗?
...全文
282 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
weiguang 2006-04-25
  • 打赏
  • 举报
回复
可以用背景音乐来试试
在html里面加上<bgsound id="sound">
在js里面加上document.all.sound.src = "xxx.wav";
anny000 2006-04-17
  • 打赏
  • 举报
回复
GaoXX(孩儿他爹) 谢谢你帮着顶!非常想搞明白这个问题,BlueDestiny(Leave For Back)的代码我也试过了,依旧是没有反映!谢谢各位,再帮帮忙了
GaoXX 2006-04-15
  • 打赏
  • 举报
回复
顶一下
BlueDestiny 2006-04-14
  • 打赏
  • 举报
回复
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript">
<!--
function ccplay()
{
document.getElementById("sy").src="wav/ZIR00002[1].wav";
}
function ccstop()
{
document.getElementById("sy").src="";
}
//--> </script>

</head>

<body onload="ccplay()">

<embed src="wav/ZIR00002[1].wav" loop=false autostart=true hidden=true width=0 height=0 id="sy"></embed>

</body>
</html>
anny000 2006-04-14
  • 打赏
  • 举报
回复
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="JavaScript">
<!--
function ccplay()
{
document.sy.src="";
}
function ccstop()
{
document.sy.src="wav/ZIR00002[1].wav";
}
//--> </script>

</head>

<body onload="ccplay()">

<embed src="wav/ZIR00002[1].wav" loop=false autostart=true hidden=true width=0 height=0 name="sy"></embed>

</body>
</html>
照楼上的方法写完,还是不可以,首先谢谢各位,不过还要请大家再仔细看一下,非常感谢
BlueDestiny 2006-04-13
  • 打赏
  • 举报
回复
<html>
<head>
<title>使用JavaScript控制网页背景音乐</title>
<bgsound id=ba>
</head>
<body topmargin="20" leftmargin="20">
<script language=javascript>
function setmusic(bs){
this.bs=bs;
this.musiclist=new Array(
"Demo",
"rainbow",
"tian",
"tianzihen",
"xintiao",
"liandie",
"dujiaoxi",
"ailis",
"airuchaoshui",
"dontaskme",
"chuangqi",
"101",
"102",
"103",
"104",
"1000song",
"romanc",
"zhuling"
);
this.at=0;
this.play=function(){
this.bs.src="./midi/"+this.musiclist[this.at]+".mid";
this.bs.loop=-1;
}
this.back=function(){
this.at-=1;
if(this.at<0)
this.at=this.musiclist.length-1;
this.play();
}
this.front=function(){
this.at+=1;
if(this.at>this.musiclist.length-1)
this.at=0;
this.play();
}
this.stop=function(){
this.bs.src="";
this.bs.loop=0;
}
}
var music=new setmusic(document.all.ba);
</script>
<br><br>
<TABLE WIDTH=47 BORDER=0 CELLPADDING=0 CELLSPACING=0 >
<TR>
<TD>
<A HREF="javascript:music.back();">
<IMG SRC="images/back.jpg" WIDTH=11 HEIGHT=11 BORDER=0 ALT="前一首"></A></TD>
<TD>
<A HREF="javascript:music.play();">
<IMG SRC="images/go.jpg" WIDTH=12 HEIGHT=11 BORDER=0 ALT="播放"></A></TD>
<TD>
<A HREF="javascript:music.stop();">
<IMG SRC="images/stop.jpg" WIDTH=12 HEIGHT=11 BORDER=0 ALT="停止"></A></TD>
<TD>
<A HREF="javascript:music.front();">
<IMG SRC="images/front.jpg" WIDTH=12 HEIGHT=11 BORDER=0 ALT="后一首"></A></TD>
</TR>
</TABLE>
</body>
</html>
anny000 2006-04-13
  • 打赏
  • 举报
回复
求助阿!!!
anny000 2006-04-13
  • 打赏
  • 举报
回复
intereye(其实我是一个程序员!) 还是不可以啊,没有反应
intereye 2006-04-13
  • 打赏
  • 举报
回复
<script language="JavaScript">
<!--
function play()
{
document.all("sy").play()==true;
}
function stop()
{
document.all("sy").play()==true;
}
//--> </script>

这样呢?没试过~~
clare2003 2006-04-13
  • 打赏
  • 举报
回复
<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--function MM_controlSound(x, _sndObj, sndFile)
{ //v3.0 var i, method = "", sndObj = eval(_sndObj); if (sndObj != null)
{ if (navigator.appName == 'Netscape') method = "play";
else { if (window.MM_WMP == null)
{ window.MM_WMP = false; for(i in sndObj) if (i == "ActiveMovie") { window.MM_WMP = true; break; } } if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run"; } } if (method) eval(_sndObj+"."+method+"()"); else window.location = sndFile;}//--></script>
</head>
<body bgcolor="#FFFFFF" text="#000000"><a href="#" onMouseOver="MM_controlSound('play','document.CS1011000896300','Notify.wav')" onMouseDown="MM_controlSound('play','document.CS1011000904810','Ding.wav')">assdfsd</a> <EMBED NAME='CS1011000896300' SRC='Notify.wav' LOOP=false AUTOSTART=false MASTERSOUND HIDDEN=true WIDTH=0 HEIGHT=0></EMBED> <EMBED NAME='CS1011000904810' SRC='Ding.wav' LOOP=false AUTOSTART=false MASTERSOUND HIDDEN=true WIDTH=0 HEIGHT=0></EMBED> </body></html>
anny000 2006-04-13
  • 打赏
  • 举报
回复
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>

<script language="javascript">
function MM_controlSound(sndAction,sndObj)
{
if (eval(sndObj) != null)
{
if (navigator.appName==Netscape)
eval(sndObj+((sndAction==stop)?.stop():.play(false)));
else if (eval(sndObj+".FileName"))
eval(sndObj+((sndAction==stop)?.stop():.run()));
}
}
</script>

</head>

<body onLoad="MM_controlSound(run,document.sy)">

<embed src="wav/ZIR00002[1].wav" loop=false autostart=false hidden=true width=0 height=0 name="sy"></embed>
</body>
</html>

这样写也不对,请指点
BlueDestiny 2006-04-13
  • 打赏
  • 举报
回复
<embed src="wav/ZIR00002[1].wav" loop=false autostart=false hidden=true width=0 height=0 name=sy id=sy></embed>

sy.src=""

要停止把src赋空值就可以了

给你的那段代码是个class,有上一首,下一首等功能。包括停止。
zhangli 2006-04-13
  • 打赏
  • 举报
回复
<OBJECT id="mmsplayer" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" name="mmsplayer">
<PARAM NAME="URL" VALUE="你要播放的音乐文件地址或播放列表">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="balance" VALUE="0">
<PARAM NAME="playCount" VALUE="100">
<PARAM NAME="autoStart" VALUE="1">
<PARAM NAME="invokeURLs" VALUE="1">
<PARAM NAME="volume" VALUE="100">
<PARAM NAME="uiMode" VALUE="invisible">
<PARAM NAME="enabled" VALUE="1">
<PARAM NAME="enableContextMenu" VALUE="0">
<PARAM NAME="fullScreen" VALUE="0">
<PARAM NAME="enableErrorDialogs" VALUE="0">
<PARAM NAME="_cx" VALUE="0">
<PARAM NAME="_cy" VALUE="0">
</OBJECT>

<script language=javascript>
/* 设置音量 */
function changeVolume(num)
{
var mmsplayer=document.getElementById("mmsplayer");
if (!mmsplayer){return false;}

var vol = mmsplayer.settings.Volume;
vol = vol + num;
if (vol > 100) vol=100;
if (vol < 0) vol=0;

mmsplayer.Settings.Volume=vol;
}
</script>

<A HREF="#" onclick="changeVolume(10);return false;">增加音量</A>
<A HREF="#" onclick="changeVolume(-10);return false;">减小音量</A>
anny000 2006-04-13
  • 打赏
  • 举报
回复
没看明白楼上的代码

87,907

社区成员

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

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