i have written a script that outputs the track playing to xml so i can view it across my network. the script runs fine but i am having problems detecting when dbpoweramp has been powered off. the script continues to run and eventually restarts dbpoweramp. is there an event that i can capture when the execution of the app is stopped?
also, what other properties are exposed by the multiplayer and amp objects?
here is the script in case anyone is interested:
Set a = CreateObject("dBpowerAMP.Multiplayer")
Set b = CreateObject("dBpowerAMP.Amp")
Call b.PowerOn
b.Volume = 100
Dim last, currFile, root
Const total = 50
Dim tune()
ReDim tune(total,3)
'directory in which to write the resulting xml file
root = "Z:\Sites\xml\"
'xml file name
tuneFile = root + "tunes.xml"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
While (a.Play)
If last <> a.FilePlaying Then
If fso.FileExists(tuneFile) Then fso.DeleteFile tuneFile End If
last = a.FilePlaying
Set f = fso.CreateTextFile(tuneFile, True)
Dim re
Set re = New regexp
re.Pattern = "\s"
re.Global = True
dim arturl, artist, album
album = re.Replace(a.Album,"%20")
artist = re.Replace(a.Artist,"%20")
arturl = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&ResponseGroup=Imag es&SubscriptionId=xxxxxxxxxxx&Operation=ItemSearch &SearchIndex=Music&Artist=" + artist + "&Title=" + album
re.Pattern = "&"
re.Global = True
tune(0,0) = re.Replace(a.Track,"&")
tune(0,1) = re.Replace(a.Artist,"&")
tune(0,2) = re.Replace(a.Album,"&")
arturl = re.Replace(arturl,"&")
f.WriteLine("<tunes>")
f.WriteLine("<now>")
f.WriteLine("<track>"+tune(0,0)+"</track>")
f.WriteLine("<artist>"+tune(0,1)+"</artist>")
f.WriteLine("<album>"+tune(0,2)+"</album>")
f.WriteLine("<bitrate>"+CStr(a.Kbps)+"</bitrate>")
f.WriteLine("</now>")
For i = 1 To total
tune((total-i+1),0) = tune((total-i),0)
tune((total-i+1),1) = tune((total-i),1)
tune((total-i+1),2) = tune((total-i),2)
If tune(i,0) <> "" Then
f.WriteLine("<prev>")
f.WriteLine("<track>"+tune(i,0)+"</track>")
f.WriteLine("<artist>"+tune(i,1)+"</artist>")
f.WriteLine("<album>"+tune(i,2)+"</album>")
f.WriteLine("</prev>")
End If
Next
f.WriteLine("</tunes>")
f.Close
End If
set WshShell = WScript.CreateObject("WScript.Shell")
If (a.Length - a.Position)>0 Then
WScript.Sleep (a.Length - a.Position)
End If
Wend
also, what other properties are exposed by the multiplayer and amp objects?
here is the script in case anyone is interested:
Set a = CreateObject("dBpowerAMP.Multiplayer")
Set b = CreateObject("dBpowerAMP.Amp")
Call b.PowerOn
b.Volume = 100
Dim last, currFile, root
Const total = 50
Dim tune()
ReDim tune(total,3)
'directory in which to write the resulting xml file
root = "Z:\Sites\xml\"
'xml file name
tuneFile = root + "tunes.xml"
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
While (a.Play)
If last <> a.FilePlaying Then
If fso.FileExists(tuneFile) Then fso.DeleteFile tuneFile End If
last = a.FilePlaying
Set f = fso.CreateTextFile(tuneFile, True)
Dim re
Set re = New regexp
re.Pattern = "\s"
re.Global = True
dim arturl, artist, album
album = re.Replace(a.Album,"%20")
artist = re.Replace(a.Artist,"%20")
arturl = "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&ResponseGroup=Imag es&SubscriptionId=xxxxxxxxxxx&Operation=ItemSearch &SearchIndex=Music&Artist=" + artist + "&Title=" + album
re.Pattern = "&"
re.Global = True
tune(0,0) = re.Replace(a.Track,"&")
tune(0,1) = re.Replace(a.Artist,"&")
tune(0,2) = re.Replace(a.Album,"&")
arturl = re.Replace(arturl,"&")
f.WriteLine("<tunes>")
f.WriteLine("<now>")
f.WriteLine("<track>"+tune(0,0)+"</track>")
f.WriteLine("<artist>"+tune(0,1)+"</artist>")
f.WriteLine("<album>"+tune(0,2)+"</album>")
f.WriteLine("<bitrate>"+CStr(a.Kbps)+"</bitrate>")
f.WriteLine("</now>")
For i = 1 To total
tune((total-i+1),0) = tune((total-i),0)
tune((total-i+1),1) = tune((total-i),1)
tune((total-i+1),2) = tune((total-i),2)
If tune(i,0) <> "" Then
f.WriteLine("<prev>")
f.WriteLine("<track>"+tune(i,0)+"</track>")
f.WriteLine("<artist>"+tune(i,1)+"</artist>")
f.WriteLine("<album>"+tune(i,2)+"</album>")
f.WriteLine("</prev>")
End If
Next
f.WriteLine("</tunes>")
f.Close
End If
set WshShell = WScript.CreateObject("WScript.Shell")
If (a.Length - a.Position)>0 Then
WScript.Sleep (a.Length - a.Position)
End If
Wend
Comment