title
Products            Buy            Support Forum            Professional            About            Codec Central
 

detecting power off

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Unregistered

    detecting power off

    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,"&amp;")
    tune(0,1) = re.Replace(a.Artist,"&amp;")
    tune(0,2) = re.Replace(a.Album,"&amp;")
    arturl = re.Replace(arturl,"&amp;")

    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
  • Unregistered

    #2
    Re: detecting power off

    here's a url to the result:


    btw, the 'de la soul' tune is repeated because of the bug i have relating to my question above.

    Comment

    • ChristinaS
      dBpoweramp Guru

      • Apr 2004
      • 4097

      #3
      Re: detecting power off

      Hmmm... I am not sure what you're trying to achieve with this web page. The only thing that is repeated now is the display of the page, because of the meta refresh every 30 seconds. I can hear nothing at all, nor did I expect to hear if you're attempting to have it run through dAP.

      Are you running your web site hosted on your own pc? Or are you trying to tap into you visitor's installation of dAP?

      Or am I way off? :D

      Comment

      • Unregistered

        #4
        Re: detecting power off

        no your way off, sorry. it's not doing any streaming, etc.

        i have a network at my house. the only thing i use my pc for these days is to store my music collection and play it. so when i am working on my mac, this webpage lets me know what track is playing, etc, without my switching over to the pc.

        however, the script continues to run when i switch dbpoweramp off. i want the script to stop when it recognizes that dbpoweramp is no longer executing.

        eventually i'd like to get a server up and running on the pc that i can control remotely from the mac, so i can queue tracks etc.

        Comment

        • Unregistered

          #5
          Re: detecting power off

          i figured it out.

          you can check what processes are running like this:

          Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
          Set colProcesses = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process",,48)

          AmpRunning=0
          For Each objItem in colProcesses
          If(objItem.Name = "Amp") Then AmpRunning=1
          Next

          Comment

          • ChristinaS
            dBpoweramp Guru

            • Apr 2004
            • 4097

            #6
            Re: detecting power off

            Originally posted by Unregistered
            no your way off, sorry. it's not doing any streaming, etc.

            i have a network at my house. the only thing i use my pc for these days is to store my music collection and play it. so when i am working on my mac, this webpage lets me know what track is playing, etc, without my switching over to the pc.

            however, the script continues to run when i switch dbpoweramp off. i want the script to stop when it recognizes that dbpoweramp is no longer executing.

            eventually i'd like to get a server up and running on the pc that i can control remotely from the mac, so i can queue tracks etc.
            Ok, so I'm being quite ignorant :p
            But I'm not all that far off to my way of thinking you are running the web site (or at least this portion of it) from your own machine(s) and using the homedns.org system of faking a fixed IP address.

            Where I was off was in my thinking that the music would be broadcast somehow :p And, more importantly, in not seeing the relationship between the script you posted and the web page you gave :o

            Are you able to tap into the Task manager and see the application and running processes? If I start dAP I see right away this application (both in the list of Aplications and in the list of processes). If dAP is actually playing a tune, then the related process (AMP.exe) is active and I can see CPU activity as well.

            Comment

            • ChristinaS
              dBpoweramp Guru

              • Apr 2004
              • 4097

              #7
              Re: detecting power off

              He-he! So at least I was on the right track it seems - though no closer to the practical solution which you found :D

              Comment

              • donny
                dBpoweramp Guru

                • Oct 2002
                • 761

                #8
                Re: detecting power off

                this is interesting... I have the same problem with QueMaster (which is probably a anoying thing for many users)... I have searched for a solution, and well this was also my idea, but I just couldn't make it work before, and then I didn't have the time to work on it... maybe I'll fix it in the next release...

                Comment

                • Unregistered

                  #9
                  Re: detecting power off

                  donny,
                  there's probably a little more efficient way to do this - i.e. querying for "amp" directly rather than selecting all and searching. i didn't play with it much as i started working on other things. i've actually set up code now so that i can control dbpoweramp remotely over the network, via a browser. i've essentially created a web based mmc.

                  so now that i can control the player over a network, the next logical step is getting it to stream. has anyone made any efforts in this area to date? perhaps this should be a new thread.

                  Comment

                  • donny
                    dBpoweramp Guru

                    • Oct 2002
                    • 761

                    #10
                    Re: detecting power off

                    I know that is more efficient, what I meant to say that when I was palying with the problem I had a problem to get proces names at all... I'll try this way, or similar

                    Comment

                    Working...

                    ]]>