I'm struggling with the following script to play a random .wav file from a network share. It return the error message of ..
Sep-09 7:22:17 PM Theater SoundClips Found 10 files. Playing:\\readynas\other\Sound Clips\Theater Sound Clips\Welcome\this theater features the latest in technology in order ETC.wav
Sep-09 7:22:17 PM Error Cannot find wave file: \readynas\other\Sound Clips\Theater Sound Clips\Welcome\this theater features the latest in technology in order ETC.wav
Of note is the fact that it return a properly named files on the file store \\ReadyNAS, but the error message seems to be looking at \ReadyNAS (missing double "\\").
Any help would be appreciated.
Public Sub Main(ByVal Parms As Object)
hs.PluginFunction("BLAB8SS", "", "SetPattern", {"00000100A",1})
dim fs, root, ndx, randomNdx
dim objFile, colFiles, strFileName
ndx=0
fs = createObject("scripting.filesystemobject")
root = fs.getFolder("\\Readynas\Other\Sound Clips\Theater Sound Clips\Welcome")
colFiles = root.Files
randomNdx = cint(GetRandomNumber(1,cint(colFiles.count)))
For Each objFile in colFiles
if ndx=randomNdx then
if lcase(fs.getExtensionName(objFile))="wav" then
strFileName = fs.getAbsolutePathName(objFile)
end if
exit for
end if
ndx=ndx+1
Next
hs.MediaPlay (strFileName)
hs.writeLog ("Theater SoundClips","Found " & ndx & " files. Playing:" & strFileName)
end sub
Function GetRandomNumber(lowerbound,upperbound)
Randomize
GetRandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
End Function