从文件中的javascript客户端脚本播放音频时出现问题,autostart = true [英] Problem playing audio from a javascript client side script in a file, autostart = true
问题描述
我正在尝试播放一个音频文件,该音频文件在单击按钮时会发出蜂鸣声.它是一个客户端脚本,音频需要嵌入到项目中.由于某种原因,除非我在对象中设置了autostart = true并嵌入,否则它无法正常工作.但是问题是,如果我将autostart = true放置,则在页面加载时和单击button时会听到蜂鸣声.如果我设置为autostart = false,那么当我单击该按钮时,页面不会发出蜂鸣声.但是我不希望它在加载页面时发出哔哔声.
I am trying to play a audio file which makes a beep when I click a button. Its a client side script and the audio needs to be embedded in the project. For some reason, its not working unless i set autostart=true in the object and embed . But the problem is that if i put autostart=true, i hear beeping when the page loads and when I click on button . If i set autostart=false, then the page doesnt make a beeping sound when i click on the button. But I do not want it to beep when I load the page.
<script language="javascript" type="text/javascript">
var button;
var label1;
function PlayIt(movname) {
var movname = eval("document." + movname);
movname.Play();
}
</script>
</head>
<body>
<form id="form1" runat="server" >
<object id="sound" width="1" height="1" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab">
<!-- classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"-->
<param name="src" value="beep-4-1.wma" />
<param name="autostart" value="false" />
<param name="enablejavascript" value="true" />
<param name="hidden" value="true" />
<embed name="sound" src="beep-4-1.wma" hidden="true" width="10" height="10"enablejavascript="true"
autostart ="false" loop="false" volume="20%" type="audio/mpeg"
lt;/object>
我正在使用Internet Explorer 8和一台64位计算机.
谢谢
I am using Internet Explorer 8 and a 64 bit computer.
Thanks
推荐答案
在这里是从js播放声音的各种不同方式的绝佳集合.有些方法与您尝试执行的操作类似.您可能会从那里得到一两个提示
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm [^ ]
Here is an excellent collection of different ways of playing a sound from js. Some of the methods are simialr to what you trying to do. You may get a hint or two from there
http://www.phon.ucl.ac.uk/home/mark/audio/play.htm[^]
这篇关于从文件中的javascript客户端脚本播放音频时出现问题,autostart = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!