I've to play a sound on the server machine when I access on certain page with a client machine.
Is that possible with classic ASP?
I've to play a sound on the server machine when I access on certain page with a client machine.
Is that possible with classic ASP?
ASP being just a scripting language doesn't offer any facility to directly play a sound clip.
But we can use the CreateObject
function to create a command shell instance and run sndrec32 (Sound recorder available in Win XP) and pass the .WAV sound file's path as an argument to it between double quotes.
Create a module file: functions.asp
Option Explicit
Dim strSoundFile, objShell, strCommand
Sub PlaySound()
strSoundFile = "C:\Path\of\some\file.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True
End Sub
In your ASP code, enter the following code at the beginning of the page where you want to make the call:
<!--#include file="functions.asp"-->
PlaySound
Reference: How-can-i-play-a-sound-from-within-a-script