[英]How to play WAV file using VBScript in HTML
如何在HTML中使用VBScript播放WAV文件?
我有以下代码,但无法正常工作。
<script type="text/vbscript" language="VBScript">
Dim strSoundFile, strCommand
strSoundFile = "C:\Sounds\Sound1.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True
</script>
我找到了另一个代码,但是如果我在HTML页面中使用它,它也无法正常工作,但是在* .VBS中它的效果很好。
Sub Play(SoundFile)
Dim Sound
Set Sound = CreateObject("WMPlayer.OCX")
Sound.URL = SoundFile
Sound.settings.volume = 100
Sound.Controls.play
do while Sound.currentmedia.duration = 0
wscript.sleep 100
loop
wscript.sleep(int(Sound.currentmedia.duration)+1)*1000
End Sub
我已找到此链接https://support.microsoft.com/es-es/kb/279022,但我不确定这是否是正确的方法...
通过BODY
标签的方式工作正常
<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer"
width="242" height="202" style="position:absolute; left:1;top:1;">
<param name="URL" value="C:\Sound1.wav">
<param name="autoStart" value="1">
</object>
可以用这个做吗?
<script type="text/vbscript" language="VBScript"> HERE </script>
我在MS Windows 7 Pro下使用IE8。
最后我能找到正确的方法做我需要的是描述在这里
基本上这个想法是跟随
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.