Announcement

Collapse
No announcement yet.

Winamp Scripting

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

  • Cool script, I really should get on making that site with plugins and script etc. After I finish making some updates to Toaster I will look into it.

    Though I think .ATFString("%lengthf%") may have saved you some time in formatting the time. I realise the tags are not documented in ActiveWinamp, I probably should have included them in the documentation. They are included in my other plugin, Toaster, though.
    Music Plugins

    Comment


    • maynardkrebs, how difficult would it be to write a script that would add the selected song to an open Nero compilation (audio CD or ISO)? That would make burning CDs an absolute snap.

      Primathon

      Comment


      • Originally posted by Primathon
        how difficult would it be to write a script that would add the selected song to an open Nero compilation (audio CD or ISO)?
        Not sure (yet) Nero does have an object interface that's accessible through scripting, but I've only given it a quick browse. If I come up with something I'll keep you posted.

        Comment


        • Originally posted by shaneh
          Though I think .ATFString("%lengthf%") may have saved you some time in formatting the time.
          Hey Shane.

          Thanks for the ATFString tip. I found the Toaster doc and that simplified things. My latest incarnation is attached. Notice the hack job using the dict object. I was looking for a way to query the media items selections directly but hit a brick wall.

          Some thoughts:
          - Having a query method for track selections similar to that for the media lib object would be useful.
          - Adding stats support in the query would be useful (#Artists, #Albums/Artist, #Tracks/Album, Total Time etc). That would have eliminated my having to calculate those values using my ugly hack.
          - Bug or Feature?: when a sendto script is invoked with nothing selected, nothing happens with the script. I added a ubound check to trap this condition (as I've seen you use in your code) but I'm wondering if this is necessary. Does the script just punt if there is nothing selected?

          thanx
          maynard

          code:

          ' ActiveWinamp Script
          ' File: sendto_Nero Cover Designer.vbs
          ' Desc: sendto script to pass the current track selections
          ' in Winamp to Nero Cover Designer
          '
          ' v1.0 11/24/2004 6:01 PM maynardkrebs
          '

          '########################
          ' CODE
          '########################
          Const ForReading = 1, ForWriting = 2, ForAppending = 8

          sel = GetSendToItems

          If ubound(sel) = 0 Then
          MsgBox "There are no tracks selected in Winamp", _
          vbOKOnly+vbExclamation, "SendTo NCD"
          Quit
          End If

          Set wsh = CreateObject("WScript.Shell")
          Set fso = CreateObject("Scripting.FileSystemObject")
          scdc = wsh.ExpandEnvironmentStrings("%TEMP%") & "\watemp.cdc"
          Set fcdc = fso.OpenTextFile(scdc, ForWriting, True)
          Set dict = CreateObject("Scripting.Dictionary")

          ' Total Hack: abusing the dictionary object as a searchable
          ' data struct for tracking the number of unique artists/albums
          ' in the current selection and deriving the cd label artist and
          ' album fields. The logic goes something like this:
          ' If:Artists Albums Then:LabelArtist LabelTitle
          ' 1 1 ArtistName AlbumName
          ' 1 >1 ArtistName Various
          ' >1 X Various Various
          '
          tSel = 0
          For Each track In sel
          key = track.Artist & Track.Album
          If Not dict.Exists(key) Then
          dict.Add key, track.Artist
          End If
          ' Get the total selection time
          tSel = tSel + track.Length
          Next
          'Assume single artist/single album then verify
          cdcArtist = "Artist=" & sel(1).Artist
          cdcAlbum = "Title=" & sel(1).Album
          bMultArtists = False
          If dict.Count > 1 Then
          'multiple albums
          cdcAlbum = "Title=Various"
          artists = dict.Items
          dict.RemoveAll
          For Each artist In artists
          If Not dict.Exists(artist) Then
          dict.Add artist, ""
          End If
          Next
          If dict.Count > 1 Then
          ' multiple artists
          bMultArtists = True
          cdcArtist = "Artist=Various"
          End If
          End If

          ' Write NCD collection info
          fcdc.WriteLine("[Parameters]")
          fcdc.WriteLine("Language=English")
          fcdc.WriteLine("[CDINFO]")
          fcdc.WriteLine("Type=Audio-CD")
          fcdc.WriteLine(cdcAlbum)
          fcdc.WriteLine(cdcArtist)
          fcdc.WriteLine("Tracks=" & ubound(sel))
          fcdc.WriteLine("Playtime=" & tSel)

          ' Write NCD track info
          i=1
          For Each track In sel
          ' Only include artist name if there are multiple artists
          If bMultArtists Then artist = track.Artist Else artist = ""
          fcdc.WriteLine("[Track" & i & "]")
          fcdc.WriteLine("Type=Audio")
          fcdc.WriteLine("Artist=" & artist)
          fcdc.WriteLine("Title=" & track.Title)
          fcdc.WriteLine(track.ATFString("Playtime=%lengthf%"))
          i=i+1
          Next

          fcdc.Close

          ' Launch Nero Cover Designer
          On Error Resume Next
          ncdPath = wsh.RegRead("HKLM\SOFTWARE\Classes\Nero Cover " & _
          "Designer.Document\shell\open\command\\")
          ncdPath = Left(ncdPath, InStr(ncdPath, " /dde"))
          wsh.Exec(ncdPath & " " & scdc)
          If E*****mber Then
          MsgBox "There is a problem starting Nero Cover Designer", _
          vbOKOnly+vbExclamation, "SendTo NCD"
          End If
          On Error GoTo 0

          Quit

          Comment


          • What Ive done with ActiveWinamp is try to map as much as possible that is possible under the Winamp API into a COM interface with a pretty much 1:1 match.

            You can do complex queiries on the media library, becase the media library lets you do those queries. The playlist and 'send to' items etc do not give you this possibility because its not possible under the Winamp API. You would have to do it yourself using your own code regardless of whether you are using ActiveWinamp or not. Generally speaking, if somethings complicated to do using ActiveWinamp, you would probably have to jump through similar hoops just using the normal Winamp API. (this doesnt apply to more complicated hooking tricks etc however).

            Stats support also isnt supported under Winamp, you would need to do this yourself normally. I wouldnt want to automatically generate these stats, as it would slow it down for when you dont want these stats.

            Its possible I could add some support functions which let you pass in an array of media items to generate some stats etc. However the idea of ActiveWinamp is it lets you write the code and do things the way you want them done, without using prewritten stuff. Basically you are making use of the primitive Winamp API, but without having to deal with all the crap and technicalities that usually goes along with writing a plugin.

            -sendto: I guess that Winamp doesnt signal the menu item if nothing is selected, so ActiveWinamp wont run the script. The checks are just done for the sake of logic, and perhaps if you try run the script using 'runscript()' or something I guess.

            Note Getsendtoitems() returns the collection of items that was last selected when a "script:" menu item was chosen. When running a script from the 'send to' menu, this is obviously the items that are currently selected. However if you call 'GetSendToItems()' at other times, (ie from playlist_* scripts) you will get the last selection.
            Music Plugins

            Comment


            • COM Lib for APE Tags

              Hey Shane.

              Thanks for the previous reply. I understand the limitations you have to work with...

              New question. Do you know of another COM library for APE tags similar to ID3COM? I've been using MP3Gain and would like to be able to "see" which files I've tagged as normalized in my library. Right now the only way I'm aware of to do this is to load the files into MP3Gain to get status

              Thanks

              Comment


              • Hello Shaneh,

                you have done a great job here.

                Thanks to your efforts I could do my "iTunes2winAmp" bridge within 48 hours. Kindly see this:

                These desktop iTunes remote widgets coded to be using the iTunes COM API can now all be redirected to winAmp.

                Not seen on the screenshot is that AndreasV's AveTunes widget would offer an iTunes list of playlists at its context menu and I even could get that redone with the excellent media library bindings!

                Really excellent job - I have only two minor issues:
                - IApplication:: put_Position() has no effect with WinAmp 5.03.
                - IMediaItem::Enqueue is slow if you have to enqueue thousands of items - I miss enqueueing the results of a media library query at a whole: Best would be to return the query as an IPlaylist* and have a IApplication:: putref_Playlist() implemented (just an idea), I could dump the contents into a temp .m3u file and shellexecute winamp on it but even that wouldn't be as seamless as double clicking the playlist in the media lib.

                TIA,

                herd

                Comment


                • IApplication:ut_Position: Yeah, thats a known issue. For some reason I couldnt find the API to seek in Winamp at the time. It is possible though, I'll add it in a future release. I left the function there so I could add it without breaking the interface, though thats kind of against COM rules... :P. You may use IApplication::SendMsg with IPC_JUMPTOTIME (106) to do it at the moment.

                  IMediaItem::Enqueue: There is an API to add a returned query to Winamp, however ActiveWinamp converts queries to its own internal "MediaItem" objects. This is done for 2 reasons:
                  1) The query needs to be freed as it is allocated by winamp.
                  2) It makes playlist items, items loaded by filename, items not in the ml etc all the same, which makes using AW much nicer.

                  Which explains why its called 'runqueryarray', as it creates and returns an array of objects.

                  The "playlist" object doesnt actually keep an array of current items, it queries them from the playlist dynamically. ie, get_Item() actually creates a MediaItem from querying winamps playlist. Thus its not too logical to return a 'playlist' as a result of a query.

                  I could, and actually did intend, to create another type of query method on the media library, that would return a less flexible query results object. This object would however let you do things like mass updates and send it to winamp etc. I would add a function to convert it to an array of mediaitems also.

                  Alternatively, I could add a function on the medialibrary that lets you pass in an array of MediaItems, and it converts it to a format suitable for sending to Winamp, ML style. Or just send it to Winamp itself. I would need to see how the ML does it to see if it uses some trick to do it quicker.

                  I downloaded and read the doc for the fake iTunes proxy thing. You state that ActiveWinamp only supports one client, though it should support as many as you like. What makes you think it only supports one client? It only supports one server/winamp instance, if thats what you meant.


                  @maynardkrebs: Sorry, Im not aware of such a component. You may be able to find some component which lets you do binary access on a file and query the tag yourself, if its in a easy parsed format. Otherwise, if there is an .exe which lets you do tag operations, its possible to get the output of cmdline programs and work with that..
                  Music Plugins

                  Comment


                  • Originally posted by shaneh
                    I downloaded and read the doc for the fake iTunes proxy thing. You state that ActiveWinamp only supports one client, though it should support as many as you like. What makes you think it only supports one client? It only supports one server/winamp instance, if thats what you meant.
                    Sorry I read something somewhere in the code samples and misunderstood that - I'll remove the false assumption. Thanks for the seek thing - worked like a charm.
                    I found out that dumping 3000 songs to an .m3u and executing winamp on it is slightly faster than enqueueing them in a loop but still not as seamless as from the media library - If you could address the issue in a later release it would be fine but in the meantime I'll gig into the IPC_** vs. WM_COPYDATA stuff. Again, thanks a lot.

                    Comment


                    • I just found another one:
                      IMediaItem returns only a partial IP-Address if the current track is a radio stream - there seems to be no possibility to get the streams display name, am I right?

                      Comment


                      • Nope I guess not. If its the current track, you can use tricks with the window title of HWND to get the winamp title. Otherwise you have to do it without the help of AW and use ReadProcessMemory if the program is not running in the same process space as winamp.

                        I will add a IPlaylist.GetTitleOfIndex() type method. Id rather not just add methods here and there, but add a whole bunch of upgrades and make a new interface, ie. ActiveWinamp.Application.2 etc. That is the proper way to do it in COM, otherwise you never know what methods are supported by the interface.
                        Music Plugins

                        Comment


                        • Adding methods is no problem - removing or altering them is.
                          Should be no problem if you are still in beta.

                          Would you mind sharing the source? I could help and e.g. integrate ID3 support into the IMediaItem... I am seasoned with COM but kinda new to WinAmp coding.

                          Comment


                          • Adding methods is no problem - removing or altering them is.
                            Should be no problem if you are still in beta.
                            Are you sure? I would think youd need to create a new interface so that applications that get your interface have an expected set of APIs to use. ie, if you get the interface x, you can assume that function foo exists. If 'foo' was introduced later, the application would crash trying to call it. It has no way of determining what functions exist other than some kind of version call. To do away with version tracking, you simply try get the interface number as high as you need, and can assume a certain level of functionality on that interface.

                            Take a look at IContextMenu,2,3, all they've done is add new methods.

                            Its not really in beta anymore, as it has been released to the plugin site at v1. In these forums was the beta I would say.

                            However.. I can add those methods and put up a release here until I accumulate enough to warrant another release and make the new functions a new inherited interface.

                            I will probably release the source to sourceforge at some point, Ive done a couple tricks with COM to get it to work in the unusual environment of a COM server implemented in a extension DLL of an .exe not intended to be one. And it'd be good to get a few people to look it over. But it will require some tidying up first.

                            You can use id3com to access ID3 tags. Take a look at the sendto_id3 export. example. Finding a copy of ID3com takes a bit digging though. I think its released as part of id3lib in source form. I dont think Id want id3 support in AW, its meant to be an interface to Winamp, and nothing more. Itd be like adding filesystem support to a calculator interface or something. To me, it makes more sense to use external 3rd party libraries to do external 3rd party stuff.
                            Music Plugins

                            Comment


                            • COM interfaces can be very useful when you have know how to work with them. I don't think people should start learning programming using COM as their first step. Maybe if Winamp itself loaded plugins as COM objects like the Explorer loads Shell Extensions, we would have a much easier life (in programming).

                              Comment


                              • I want to create a script that will reduce a song's playcount by 1 if it is skipped in the first 10 seconds or so. Then if your playlist is shuffling along and you skip a song, it doesn't show up as if you've played it. It should be pretty simple but I'm just learning how to do all this so I need a little help. I'm not sure how I can have a script constantly running in the background, without having to loop continuously and bog down the system. Is this possible?

                                Comment

                                Working...
                                X
                                😀
                                🥰
                                🤢
                                😎
                                😡
                                👍
                                👎