VBS播放没有对话的声音

时间:2014-03-13 00:52:36

标签: vbscript

有没有办法在VBS中打开声音而没有对话?

这是我的代码......

intAnswer = _
    Msgbox("Do you want to play welcome.mp3?", _
        vbYesNo, "Play Song?")

If intAnswer = vbYes Then
    Msgbox "Opening..."
    `play %userprofile%/directory/welcome.mp3 with no dialogue`
Else
    Msgbox "Not opening..."
End If

1 个答案:

答案 0 :(得分:10)

您可以使用Windows Media Player脚本对象WMPlayer.OCX在VBScript中播放MP3文件。

Dim oPlayer
Set oPlayer = CreateObject("WMPlayer.OCX")

' Play audio
oPlayer.URL = "C:\welcome.mp3"
oPlayer.controls.play 
While oPlayer.playState <> 1 ' 1 = Stopped
  WScript.Sleep 100
Wend

' Release the audio file
oPlayer.close