Winamp Scripting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • shaneh
    Major Dude
    • Jan 2004
    • 1193

    I actually had a script that did just that, but Ive since deleted it.

    You dont need to loop continuously, I have supplied a 'change song' event that you can respond to. AW will only invoke your method when the song changes.

    It would look similar to:

    ---startup_playcount fix.vbs-----
    Dim pos, timerid
    timerid = -1
    pos = -1

    Sub Application_ChangedTrack
    if (timerid <> -1) Then
    CancelTimer timerid
    End if

    pos = playlist.position
    set mi = playlist(pos)
    mi.playcount = mi.playcount - 1
    timerid = SetTimeout (10000, GetRef("IncCount"))
    End Sub

    Sub IncCount
    if (playlist.position = pos) Then
    set mi = playlist(pos)
    mi.playcount = mi.playcount + 1
    end if
    tiemrid = -1
    End Sub
    -----------------

    Be aware that this will fuck up with songs less than 10 seconds long etc. And probably a few other cases like when the song is not in the ml, has a zero playcount, http streams, you move the song in the playlist during play etc etc. I will probably release a proper plugin that does this a bit more robustly, does calculations based on song length etc if you can wait.

    A better script would probably store the filename of the currently playing song then check that after 10 secs rather than the current playlist pos. Or cache the "mi" and check the filename of that vs the currently playing filename on the timer event. Left as an exercise...
    Last edited by shaneh; 11 December 2004, 04:20.
    Music Plugins

    Comment

    • ¿¢?
      Feed me a stray dog
      (Major Dude)
      • Oct 2004
      • 1122

      Hi, just thought I'd post a script I've been using in case somebody else could use it. This is just a simple modification of the playllist_Rand items script that comes bundled with A/W. It enqueues 100 random songs that haven't been played in the last 7 days.


      dim i,j,Dict1,keys,tracks,num,idxs

      Set Dict1 = CreateObject("Scripting.dictionary")
      Dict1.CompareMode = BinaryCompare

      mlq = medialibrary.runqueryarray("type = 0 AND !(lastplay >= [7 days ago])")
      i = 0

      for each track in mlq
      Dict1(track.artist)=Dict1(track.artist) + ":" + CStr(i)
      i = i + 1
      next

      Randomize
      itms = Dict1.Items

      num = 100

      do while (tracks<=num)

      Rand = Int(Dict1.Count * Rnd+1)

      idxs = Split(itms(Rand), ":", -1, 1)

      Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
      mlq(Rand2).enqueue

      tracks=tracks+1
      Loop

      quit




      Dunno if it's cool to post simple modifications like this but hey maybe somebody can use it. They can change the part that reads "!(lastplay >= [7 days ago]" to read "lastplay issempty" if that's more to their liking.

      I guess I'm just posting it to show how I've been using ActiveWinamp, & to show that even somebody who doesn't know how to write code can customize a script to get something that suits their usage.

      Have a good one and thanks,


      /edit p.s. Shaneh, would you consider adding year as a supported value for future versions of A/W? It would be cool to be able to enqueue or insert random all from year.

      Comment

      • shaneh
        Major Dude
        • Jan 2004
        • 1193

        Ah.. left "Year" out, plus a couple other things. Will put 'em in a future version. Fortuantly most things can be covered with "sendmsg" and 'ATFString' hacks.

        To get the year, using mi.atfstring("%year%") should work.
        Music Plugins

        Comment

        • ¿¢?
          Feed me a stray dog
          (Major Dude)
          • Oct 2004
          • 1122

          That is where it goes over my head. I am fine with waiting for a future version, should you wish to accomodate it. Year is not very high in my priorities, although it would be neat.

          Comment

          • neFAST
            Member
            • Sep 2004
            • 56

            Re: Three from One script

            Originally posted by CaAl
            I've written a script that automatically enqueues a song each time a new song is played, in such a way that you'll get three songs in a row from a random artist, followed by three in a row from another random artist. Toggling the script on/off can be done via the configurationwindow of Shaneh's plugin.
            Would be nice if we could switch a script on or off with a right clic instead of the config window ...
            I'm planning to write a "party shuffle" similar to Itunes' one using this "active script" feature. But it would be very useful to lauch or stop it quickly from the "Script" menu !

            Comment

            • neFAST
              Member
              • Sep 2004
              • 56

              Finally I decided to trigger "Three from one" with a specific track header. So when I launch my playlist with that fake track, 3from1 is active. And when i listen to a track or an album it's off.

              But (cause there's a but) it seems that Activewinamp won't remember the choose "Running Scripts" after a restart !

              Anything planned to fix it ?


              code:
              ' +----------------------+
              ' | Three from one |
              ' +----------------------+

              ' Automatically enqueues a new song each time a song is played. Plays 3 songs in a row per artist
              ' Written by CaAl

              Dim playingartist, playingtitle, prevartist, prevtitle, prevprevartist, mlq, q1, q2, q3
              Randomize

              Sub Application_ChangedTrack

              if playlist(1).filename="X:\-----Three from One--------------------------.x" then

              ' Reading in the required artist/title-fields. Assumption: all songs have ID3 tag. If not, bad things could happen, but I don't really care
              playingartist = playlist(playlist.position).artist
              // code ....
              end if
              End Sub

              Comment

              • shaneh
                Major Dude
                • Jan 2004
                • 1193

                AW doesnt remember 'running scripts' in the same way Windows doesnt remember running programs. If you want something to start at startup, name it 'startup_x.vbs'.

                You could write a startup script which checked an .ini file and launched any other scripts depending on whether you want them to run at startup.

                AW currently just uses the running script dialog for running scripts. I may include another sub menu for running scripts which lets you stop them more easily. Theres a bit I need to do with regards to script management (hot key callbacks, menu item registering/callbacks, etc etc..).
                Music Plugins

                Comment

                • neFAST
                  Member
                  • Sep 2004
                  • 56

                  your right, startup mode is exactly what i was looking for ! I thought startup would only launch the script once.

                  I've another question, I was still using gen_script.dll and I recently installed the gen_activewa.dll version.
                  Since my script computing a "smart random" is now 10 times slower than before !!!
                  The query medialibrary.runqueryarray("type = 0") takes ages to complete with big libraries

                  Any idea to optimize that ?

                  Comment

                  • shaneh
                    Major Dude
                    • Jan 2004
                    • 1193

                    Im guessing theres an issue with the meta data retrieval on creation of a "MediaItem". I will look into it soon.
                    Music Plugins

                    Comment

                    • Wabiloo
                      Member
                      • Sep 2002
                      • 62

                      Help file?

                      Hi, and sorry for this stupid post, but...

                      I just installed ActiveWinamp, downloaded from the plugin pages, and all reviews mention a help file. However, I can't find it. I can see the scripts in "Scripts" and some external applications examples in "AWExamples", but cannot find the help file...

                      [edit]
                      Found it, if it's gen_activewa.chm.
                      Apparently I can't delete my post so it'll have to stay...
                      Never mind he!
                      Last edited by Wabiloo; 11 January 2005, 18:09.

                      Comment

                      • Wabiloo
                        Member
                        • Sep 2002
                        • 62

                        Originally posted by shaneh
                        You need to put id3com.dll wherever you like, then run

                        regsvr32 id3com.dll


                        I tried the same thing with id3lib.dll v3.8.3 downloaded from their sourceforge website, but got the following message:
                        "id3lib.dll was loaded, but the DllRegisterServer entry point was not found.
                        This file can not be registered."

                        Any idea what could be the problem? (sorry I'm not used to programming under Windoze)

                        Comment

                        • shaneh
                          Major Dude
                          • Jan 2004
                          • 1193

                          id3com not id3lib.
                          Music Plugins

                          Comment

                          • Wabiloo
                            Member
                            • Sep 2002
                            • 62

                            Originally posted by shaneh
                            id3com not id3lib.
                            Ah, OK, not the same thing. I read the id3com is a wrapper, whatever that means.
                            Couldn't find a compiled version in their distribution though, so I had to find it somewhere else.
                            Do you have any idea where I could find the object reference for it?

                            Comment

                            • saivert
                              Banned
                              • Jan 2001
                              • 927

                              ID3Lib is a completely different project. You don't even need ID3Lib cos' ID3Com has built in functions for reading tags.

                              Comment

                              • Wabiloo
                                Member
                                • Sep 2002
                                • 62

                                A playlist event

                                Is it possible to create a ChangedPlaylist event, that would be triggered every time the playlist is modified (addition, deletion, swap, etc.)?

                                This is for me to write an external application that would interact with current software I'm using so that I have total control over the playlist, but can still let other applications change the playlist and be aware of the changes.

                                Comment

                                Working...
                                X