PDA

View Full Version : Winamp Scripting


Pages : 1 [2] 3

DrO
8th April 2005, 17:26
saivert: i missed that bit of your post (was skim reading whilst at work)

-daz

shaneh
9th April 2005, 00:37
@antu^jamban: If the file isnt found in the ML, it tries the extended_info call instead. Obiously calls to get rating and playcount etc will not return anything useful. Take a look at the code in mediaitem.cpp to see how it goes.

@saivert: I dont keep a log as such, but you can follow the trackers in soureforge and see the cvs logs etc. Im tempted to do another release soon, as Ive fixed quite a few important bugs. Though I would lke to work on internal scripting support a bit more first, and support for some more stuff such as video and equalizer things etc.

saivert
9th April 2005, 12:52
I see you are goig for a Wiki style page for ActiveWinamp.sf.net. Nice. Then people can post their own examples there for others to see.

grahamskaraoke
28th April 2005, 03:23
Developing a program using your excellent plugin and went to install it on a windows98 machine. Winamp does not show it listed in the general purpose plugin section. Is there any extra steps I need to use it on Windows 98. I ran the active winamp install and did not show any errors. The plugin and help file are in the plugin directory. I am also running gen_scripting.dll as there was a couple of things that I in my ignorance could not figure out how to do in Active Winamp.
Thanks for all the hard work.

shaneh
28th April 2005, 03:55
Thats very strange that its not shown in the list of plugins. I don't program with compatilibty with '98 etc anymore (just as I dont program for compatability with DOS), but it should at least be shown in that list I would think. I'm guessing Winamp is failing when trying to load the .dll and silently not doing aynthing about it. Possibly because of a missing dependency, use dependency walker to check if this is the case (you can ignore the mpr.dll missing import):
http://www.dependencywalker.com/

What is it you could not do with ActiveWinamp? Most likely there is a way.

Also, make sure you copy over the latest version of gen_activewa.dll from the CVS after you install it. Theres a fair few updates, but nothing that would increase compatability with 98 I wouldnt think.

grahamskaraoke
28th April 2005, 05:31
Really appreciated the quick reply shane. I will try the dependency walker as soon as I get access to that machine again. As for what I couldn't figure out I've got to go through the code and will let you know. Could it possibly be a conflict between active WA and gen_scripting.dll. Works great on XP.

Does the release version on sf.net contain the support for multiple instances of winamp, or is that still being worked on.

Little background. I've been a karaoke/disc jockey for twenty years and recently had major surgery and cannot work right now so decided to have a go at creating the ulitmate software (IMHO) benefiting from my years of experience.

Thanks for the excellent software/support.

shaneh
28th April 2005, 05:43
I don't think it is a conflict problem. At the very least you should be seeing it in the list, so I suspect it is a failure to load the .dll problem.

The multiple instance support is kind of difficult, its currently not supported in the cvs version, and the version posted in here that has the support has a variety of other problems. Im not sure whether I will support it, there are various technical reasons why not. will see.

You might be interested in taking a look at MediaMonkey for your purposes, it has some nice inbuilt scripting support and is in active development unlike Winamp. It also supports a lot of winamp plugins. Not sure about the multiple instance support though.

grahamskaraoke
28th April 2005, 17:41
Thanks Shane I'll check it out.

saivert
29th April 2005, 06:20
Re: About the multiple instancing problem
When someone call the ActiveWinamp object when Winamp is not running, is it launching Winamp with the /class parameter then? Maybe it could do this to make sure it know which Winamp it is controlling. And you could call a method on the ActiveWinamp root object called SetWinampClass(string) that tells the object which Winamp to use. Just an idea.

And can you use the Window Station/Desktop API to obtain the handle of a running Winamp when the ActiveWinamp object is called from ASP script? Maybe it requires the "Allow interaction with logged on user" privilege or something similar. Or maybe the only way for a process that is started under a non-logged on user (i.e. SYSTEM, or IADM_USR, whatever) to communicate with a program running under the logged on user is by using named pipes.

shaneh
29th April 2005, 11:19
The problem is quite tough. I havent actually seen an app which handles it too well. Being a single document interface app, with the possiblity of being launched in either single instance or multiple instance mode makes it even trickier.

Coupled with the fact the COM server is handled in a .DLL which is part of an EXE which actually itself isn't a COM server doesn't help. Ive been thinking about making the COM server another .exe which actually launches winamp.exe (possible with a /class param), or just have the /class included as a param for the com server.

Knowing which instance of winamp AW is controlling isn't really much of an issue, as it can just control the in-process instance. The trouble is the way AW grabs this instance is by registering, then getting, the active object. Its the 'active object' problem that is causing issues, and seems to cause issues for many com servers.

Feel free to checkout the source and have a go at implementing it. You will want to look into mo****rs too probably. And make sure it works with 'createobject' and 'getobject', in both single instance and multiple instance mode. And when winamp isn't and is already running.

Anyway, its complicated...

grahamskaraoke
1st May 2005, 04:24
Once again I need a little help shane. How can I get the length of the currently playing song from your plugin. This is so I can figure the percentage played and near the end (94%) load the next song.

I did try Media Monkey but I found it not as stable as Winamp. To get around my previous problem I am using Winamp 2.95 with gen_scripting.dll and Active_WA on winamp 5.08. This gives me the multiple instances I needed. Thanks for any help.:rolleyes:

shaneh
1st May 2005, 06:08
You can just use the .length property of a media item. ie, playlist(3).length

or

set mi = loaditem("C:\song.mp3")
mi.length

or wherever else you obtain a media item. Im not sure if works perfectly if the item isn't in your ML, but hopefully it will.

Be warned that the length is often wrong. This will be the case regardless of whether you are using this plugin or not. Even winamp displays the wrong time sometimes and the 'time remaining' display just works in over time as it tries to catch up. I have no idea why this error occurs, something to do with the .mp3 format and difficulty in getting an accurate time I suppose.

The other way is to poll winamp for the length and time elapsed etc, it tends to get more accurate the longer the item is played. You probaly wont find an elegant solution to what you are trying to do, no-one else has.

Use this with SendMsg. ie:

#define IPC_GETOUTPUTTIME 105
/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME);
** returns the position in milliseconds of the current track (mode = 0),
** or the track length, in seconds (mode = 1). Returns -1 if not playing or error.
*/


length = SendMsg(1024, 1, 105)

maynardkrebs
7th May 2005, 07:07
Attached is a zip file containing some scripts I've created. Hope they are useful...

sendto_File Copy.vbs - Copies selections in Media Library to specified destination folder.
sendto_File Move.vbs - Moves selections in Media Library to specified destination folder.
sendto_File Delete.vbs - Batch deletes selections from Media Library without warning prompts for each file as does the standard WA delete operation.
sendto_MP3Gain.vbs - Launches MP3Gain with selections in Media Library.
sendto_Nero Cover Designer.vbs - Launches Nero Cover Designer with selections from Media Library and populates NCD layout with Artist/Album/Track info.

TBD
Change Copy/Move operations to use configurable ATF for folder destination (ex. <Artist>\<Album>\<File>)

Cheers
Maynard

shaneh
7th May 2005, 09:42
Nice contribution maynardkrebs, you can also add scripts to the ActiveWinamp wiki to easily update/share/have others edit etc.
http://activewinamp.sourceforge.net/doku.php?id=examples:root

I hope to have a new release of AW out sometime soon, as there are quite a few bugs already fixed in the CVS version. You should definetely use the version available in the CVS at the sourceforge site, as some bugs that have been fixed are a bit problematic.

maynardkrebs
7th May 2005, 15:04
hey shane.

Glad you found a home for AW. Thanks for tip on latest versions at sourceforge.

maynard

roytam1
9th May 2005, 01:46
Attached is a zip file containing a script I've created. Hope it is useful...

startup_randsong.vbs - Random play of current playlist, needs regsvr32 MersenneTwister.dll to use.

and MersenneTwister.dll is a fast random number generator in ActiveX DLL form.

neFAST
20th May 2005, 00:23
Here's is a "iTunes party suffle"-like i wrote.
Use it in combination with a playlist containing#EXTM3U
#EXTINF:-1,X:\¯¯¯¯¯¯Party Shuffle______________________
X:\¯¯¯¯¯¯Party Shuffle______________________.x
I plan to check the number of tracks in playlist to maintain its size to 25
' +----------------------+
' | Party Shuffle |
' +----------------------+
' Automatically enqueues a new song each time a song is played.
' Brought to you by neF4ST

Dim mlq,mlq2,artist,tracks
Randomize

' "smart" random slightly faster with big libraries
mlq = medialibrary.runqueryarray("type = 0 and trackno = 1")

Sub Application_ChangedTrack

if playlist(1).filename="X:\¯¯¯¯¯¯Party Shuffle______________________.x" then

if playlist.position=1 then
' This is the first launch
' we add 20-1 songs
do while (tracks<=19)
Rand = Int(ubound(mlq)*Rnd+1)
mlq2 = medialibrary.runqueryarray("artist = """ + mlq(Rand).artist + """")
Rand2 = Int(ubound(mlq2)*Rnd+1)
mlq2(Rand2).enqueue
tracks=tracks+1
Loop
'now let's play
play
end if

if playlist.position>5 then
' We add a new song
Rand = Int(ubound(mlq)*Rnd+1)
mlq2 = medialibrary.runqueryarray("artist = """ + mlq(Rand).artist + """")
Rand2 = Int(ubound(mlq2)*Rnd+1)
mlq2(Rand2).enqueue

' We remove the first song of the playlist
playlist.deleteindex(2)
end if

end if

End Sub

grahamskaraoke
24th May 2005, 22:34
Shane I got another dumb question for you. The song that is currently playing in Winamp when there is a blank playlist. Is there a way to get artist tile for the currently playing song.

i.e. Someone uses the loadfile dialog from the winamp interface. Calls to the playlist.item.whatever show up as member item does not evalueate to object. Thanks

saivert
25th May 2005, 08:58
Using Load file dialog (or as I like to call it Open Song) will add the song to the playlist. Winamp always does this. It first clears the playlist, then adds the song to it and starts playing. If someone clears the playlist while the song plays, no info about song can be retrieved as the playlist is empty.

Winamp has major flaws in it's API and currently no one at Nullsoft is caring shit about it. I wished Peter Pawlowski did something to the API the short time he spent at Nullsoft, but nooo. Instead he got fed up and started on his own player (Foobar2000) which has an extensive C++ class based API more powerful than Winamp can ever dream of with it's simple window message/struct system.

I'm also wondering if I should quit Winamp development and focus on one of the more up to date players. Maybe give fb2k/MediaMonkey a try. Implement free form skinning for fb2k based on code from the Wasabi project (which was a good start but lacked a dedicated dev team).

Just my 2 cents...

billyvnilly
2nd June 2005, 16:41
hey shane, ive learned to make a few scripts from all of your examples, but have yet to understand how to do 2 things in one script.

I (and others asking in tech support) would really like it if you could provide a 'sort by album and then track' script.

many thanks

shaneh
6th June 2005, 12:33
Ive added this example to:
http://activewinamp.sourceforge.net/doku.php?id=examples:playlist:sort_by_album_then_track

saivert
6th June 2005, 19:37
This is more an informal post:

I just love the wiki you set up. Now I never ever have to watch these forum pages with some posts messing up the layout with those very long code lines. People can now posts their examples on the wiki and have them fixed (if any errors are present).

benedict101
20th June 2005, 11:17
Hello,

I've just discovered ActiveWinamp and it seems like the perfect solution to a problem I'm having.

I'm creating a HTA based media centre (aka HTPC) that uses freeware software to do all the playback. Obviously all of the software has to be controlable without it's interface showing so ActiveWinamp is a great solution.

The one thing that seems to be missing from ActiveWinamp is the ability to seek in a file. Is this feature possible? Is it currently impliment and I'm being very stupid?

Cheers
Benedict

shaneh
20th June 2005, 11:27
Get the latest gen_activewa.dll from the CVS and use the application.position = x property.

kyllingfot
20th June 2005, 17:17
I have a query about ActiveWinamp.

It seems it triggers the Application_ChangedStatus twice if you are already playing a file and then press play in Winamp (starts playing from the beginning). Is this the wanted behaviour (feature) or not (bug)? And both times the PlayState is reported as being '1'.

shaneh
20th June 2005, 23:05
Yes thats probably buggy, but then so is the song notification event system from Winamp (actually there isn't really one). Its also buggy in that it doesn't trigger when a http stream title changes. Its a difficult problem with many hacks involved to do well. For example Toaster goes to great lengths to just detect these track change events without these problems, most other plugins which do track change event stuff just poll the winamp window title every few ms and look for changes, which is a bloody terrible way of doing it.

Youre welcome to look at the code and submit changes, the necessary code is in PLWndProc of ScriptManager.cpp:
http://cvs.sourceforge.net/viewcvs.py/activewinamp/activewinamp/ScriptManager.cpp?rev=1.7&view=auto

jsonnabend
19th July 2005, 20:13
I'm a big fan of ActiveWinamp. Quick question: is there any way to insert an item into the playlist at position x? I'd like to find the currently playing index and insert an item immediately after it.

TIA

- Jeff

saivert
20th July 2005, 14:37
Yeah! I think it's a long time ago since ActiveWinamp only was a proof of concept. Now the code has grown and everyone is free to contribute if they want.

I'm going to get the latest revision from CVS, and have s serious look at the code.

shaneh
21st July 2005, 12:43
@jsonnabend:

You first create the item as a MediaItem, then call its insert method. See:
http://activewinamp.sourceforge.net/doku.php?id=examples:playlist:enqueue_a_file

@saivert:
The code is a bit of a mess because its been hacked up over time, it really needs to be cleaned up. But it'd be great to have others looking into it. The current cvs version already fixes a number of bugs, and Id like to get a bunch of interface improvements done soon so I can get out another release rather than have people using the buggy version.

saivert
21st July 2005, 16:53
I am working on a module called wa_getplselitems that should make it easier to get the selected items in the playlist. All you have to do is to include the wa_getplselitems.h file and link with wa_getplselitems.c. Then read comments in wa_getplselitems.h for example usage. I'm using the code from the AW project, but I'm using a real C array instead (using malloc, realloc and free).

abu
26th July 2005, 13:25
Hi,
I'd like to remove an item from the media library. Can this be done with ActiveWinamp?
Reason: I remove a file from harddisc in my VB script, but it still shows up in the ML. I have to "delete dead files" manually, which I'd like to avoid.

Thanks,
Achim

shaneh
27th July 2005, 21:23
AFAIK this currently can't be done. However modfying/updating etc the ML is something that will be included in the next release of ActiveWinamp. I will try get these features in soon so that people can at least use the CVS version to do these things, while I work on some of the other stuff which will hold back the next release for a bit.

saivert
27th July 2005, 22:51
Yeah! That's right. Let him work.

I know for a fact that the next version of ActiveWinamp will kick ass. shaneh (http://forums.winamp.com/member.php?action=getinfo&userid=132608) told me so.

Just a question:
Will ActiveWinamp use a preferences page in the next version and have a nice script editor on a separate prefs page? I once did this in my NxS Script Control (the plug-in I abandoned when you released ActiveWinamp). I can send you the code (I still kept it around in case I wanted to pick it up again).

revvd
28th July 2005, 04:39
Hi, is it possible with ActiveWinamp to write a script that saves the current playlist with a certain name? (I want to temporarily swap out the current playlist by saving it to a name that includes the date and the current playlist index.)

Thunder Pussy
30th July 2005, 06:00
Hi, still using ActiveWinamp to make some great playlists. I need a hand with this one that a friend help me with. What do I need to do to this script to make it insert the tracks after the currently playing file rather than enqueue them?

dim i,j,Dict1,keys,tracks,num,idxs
Set Dict1 = CreateObject("Scripting.dictionary")
Dict1.CompareMode = BinaryCompare
x = playlist.getselection()
mlq = medialibrary.runqueryarray("type = 0 AND lastplay isempty AND genre = """ + x(1).genre + """")
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-1) * Rnd)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
mlq(Rand2).enqueue
tracks=tracks+1
Loop
quit


Thanks for helping,
M


p.s. Will version 2 include support for year? I hope so.

saivert
30th July 2005, 22:17
You can get year thorugh the ATFString method. Just do ATFString("%year%") and you have it.

There is a lot of work for ShaneH to do before we will see a ActiveWinamp. A year property will probably be added for the next version (1.5 or something).

I will continue to check the last CVS revisions (if ShaneH has updated it).

Thunder Pussy
31st July 2005, 11:38
I got it sorted out. I had to change

mlq(Rand2).enqueue

to

mlq(Rand2).insert(x(1).position)


Cool.

saivert
31st July 2005, 17:39
@¿¢?: Please add your scripts to the ActiveWinamp wiki so other can benefit from your work. And why do you have that hard to read nick? Use plaintext nick. It's so much easier. You are a n00b with that nick. Thinking it is cool and all that. IT*S NOT FRIGGIN COOL WITH NICKS CONTAINING CHARACTERS OUTSIDE A-Z RANGE.

Thunder Pussy
31st July 2005, 20:47
Well.



I haven't put any of the scripts I use in the wiki because I don't feel that I've written them. I don't have the slightest technical knowledge about coding or scripting. All I do is take the examples that are included with the activewinamp package and modify them to suit my listening habits. Anybody who understands media library queries can do this. If I were to add them to the wiki I would feel like I was taking credit for work that I hadn't myself done, because all I'm doing is changing a word here & there. If you go back and look, all of my posts in this thread are very basic questions that if I knew how to script I wouldn't even have to ask.

If shaneh doesn't object to me putting these scripts in the wiki then I'd be proud to.




As far as the nick, I think it looks cool. You type it using the alt key & the number pad. Pfft.

billyvnilly
31st July 2005, 22:28
i put mine up, and i copied directly from shaneh. but it would have taken other people a long time to figure out how to do what i did. imo, 70% of users arent coders. any bit can help.

saivert
1st August 2005, 01:04
Oh yeah. Spanish upside down question mark blended with a cent and a regular question mark. That rocks my computer so much the harddrive spins out of sync. Alt-0191, Alt-0162, ? So very advanced and quote: "pfft".

Stop being so pestering and get a real nick. Shaneh has other things to do than looking at this shit.

Use the Wiki for what it's worth. Other people can then just fix code right there.

Actually: Using Winamp requires you to be a coder since it's so much shit you must do to get everything right.

shaneh
1st August 2005, 02:10
@¿¢?: Yes, good to see youve worked it out. A lot of people seem to have trouble with the insert method for some reason. There is an example in the wiki to do it, but the next version will hopefulyl have some better docs and at least a link to the wiki. As saivert said, you can get the year through ATFString but I will try make more things properties hopefully.

Feel free to add whatever you like to the wiki but use your best judgement. Small changes to existing scripts probably arent necessary, but if you think itd be helpful or useful to someone by all means throw it up.

If its inappropriate, I or someone else can easily roll it back or edit it, thats the idea of a wiki. You can add your own section or have them all in a single page or whatever you feel is best.

@saivert: try calm down a bit. its just a nick, its not offending anyone. For someone that doesnt have much 'technical knowledge' perhaps it is 'cool', it really doesnt matter either way.

revvd
6th August 2005, 03:17
ActiveWinamp scripts don't seem to be working for me anymore, and I haven't figured out why. I did upgrade from Winamp 5.093 to Winamp 5.094 two days ago so I'm wondering if that could possibly be it ...

Is ActiveWinamp running ok with Winamp 5.094 for anyone?

nilstastic
9th August 2005, 09:54
Same problem here.

shaneh
9th August 2005, 11:24
Works fine for me. Exactly what isn't working? I assume the script menu is appearing? Do simple:

msgbox "hey"
quit

scripts work? There is a bug where if 'format titles using ATF' isn't selected it won't be able to 'getselection' at all. Also, make sure to get the dll from the cvs and use that instead.

revvd
11th August 2005, 06:45
Thanks for the reply Shane.

> There is a bug where if 'format titles using ATF' isn't selected it won't be able to 'getselection' at all

It looks like that's what I was encountering. I turned that option back on and ActiveWinamp's working fine with Winamp 5.094.

billyvnilly
14th August 2005, 03:55
im curious if someone can make me another script. It should take the rating of a file and enqueue the file that number of times. so after all is said and done, songs with ratings 0 and 1 have 1 entry in the playlist, songs with a rating of 2 exist twice in the playlist, songs that have a rating of 5 will be in the playlist five times.

I forgot who actually came up with this idea (its somewhere around here in the forum) but this method will help influence the shuffle based on rating. they were doing it manually.

CaboWaboAddict
16th August 2005, 21:54
Hey Shane, finally did some playin' around with your lib and I really must say I'm impressed.

Do you have any Docs written up for it yet?

vitalyb
3rd September 2005, 10:53
Originally posted by shaneh
AFAIK this currently can't be done. However modfying/updating etc the ML is something that will be included in the next release of ActiveWinamp. I will try get these features in soon so that people can at least use the CVS version to do these things, while I work on some of the other stuff which will hold back the next release for a bit.

Isn't it possible to use the MediaLibrary.SendMsg function to do that? I am just not sure which message.

shaneh
3rd September 2005, 13:34
Yes it would be possible, however the IPC's for updating items in the ML require a pointer to a buffer in-process which contains the item information. Not very easy or plausible with VBscript or from an external app. It kinda defeats the purpose of using ActiveWinamp to use a hack like that.

The rating and playcount meta data can already be updated by simply setting the properties, this is not difficult to add for the other meta data too, just not as necessary so wasn't done. I also want to make some better APIs for accessing/enumerating all the extended_info meta data, not just a fixed set.

@CaboWaboAddict: The docs are included, plus the type library info is included as part of the lib. Plus there is a wiki, though its currently broken thanks to sourceforge, Im fixing it atm.

vitalyb
3rd September 2005, 14:07
Originally posted by shaneh
Yes it would be possible, however the IPC's for updating items in the ML require a pointer to a buffer in-process which contains the item information. Not very easy or plausible with VBscript or from an external app. It kinda defeats the purpose of using ActiveWinamp to use a hack like that.

The rating and playcount meta data can already be updated by simply setting the properties, this is not difficult to add for the other meta data too, just not as necessary so wasn't done. I also want to make some better APIs for accessing/enumerating all the extended_info meta data, not just a fixed set.

I'll elaborate on what I'm working on then. Basically what I am trying to do is an app (C#) that lets you rename/move files easily from the media library and as it still retain the rating/last_played/play_count - Basically what you did with "Export/Import ratings to ID3" but automatically.

Problem is, once I change the filename, the item does no longer exist in library. So I can't reinstate its previous stats in the media library until it is there once again.

I even tried looking into simulating the drag&drop behavior of the library but still without luck.

Suggestions?

shaneh
3rd September 2005, 14:30
Thats currently not possible, but something I will eventually add. The problem is the meta data update methods currently only 'update', not 'add or update'. I guess all thats really needed is an 'medialibrary.additem(mediaitem)' method, which would let you add an item using the meta data in the mediaitem if its supplied.

Alternatively, if you have a MediaItem object which was obtained from the ML, and you change the .filename propery, I could make it do an add, using the meta data contained in the object. Its something I would need to think about, because that would be kind of high-level behaviour which I want to avoid.

It can acutally update more than just rating and playcount, you can modify title, album, genre etc too, I just forgot I had added that.

The only way to currently do something like that would be to send a 'refresh library' IPC to the ML after moving the files around. It wouldnt work too well. Otherwise you can mdofiy the source to ActiveWinamp to use add/updates instead of just updates, or to do what I described above.

vitalyb
3rd September 2005, 20:17
Hey.

I changed the message to ADDORUPATE and added a SET property to filename. All seems to be working great =) I can add new items from C# now. I am also going to add a "Delete from ML" function to the COM object.

Thanks for your help :).

Do you want me to do anything with that? I am not usual to working with CVS so I am not sure how (or if I can) do anything there.

shaneh
4th September 2005, 00:25
You would need CVS write access which requires me to add you as a dev. TortoiseCVS is a nice client if you ever want to use CVS under windows.

Anyway, you can email me those patches if you like, however Im not sure if I would add them as is. The reason why I used 'update' rather than 'addorupdate' is because I didn't want items to be added to the ML when changing meta data on items that weren't in the ml behind the scenes like that. For example, using LoadItem(c:\song.mp3) then changing the artist/title etc on that item shouldn't just add it to the ML. Adding an item to the ML should be a deliberate action IMHO, and not a by product of changing meta data.

So I would need to think carefully about how I would go about it. I think the idea of using additem(mediaitem) would work best, Im still sceptical about having the filename property read/write coupled with such high level behaviour. I think read only would be better, as it closer reflects the reality of the ML API. Thus people using AW write code that works well with the underlying API, rather than the higher level API without realising whats happening behind the scenes. Though this is just my opinion.

Unfortuantly, its not great practice to go about changing the API or behaviour randomly. Id recommend not distributing anything built on custom versions of AW, as it would break if the official version was installed.

Unfortuantly this puts you and others in a difficult situation as you need functionality which hasn't been provided, and may not be able to wait for an update - which has unfortuantly been a long time coming.

Ive said it before, but hopefully in the next couple weeks I will have some updates to AW and ml_tree happening.

JPLEWIS01
4th September 2005, 20:49
Does anyone have any C# sample projects or complete script samples I can get my grubby mits on. I'm a noob with respect to C# even worse when it comes to COM interop and I'm just not getting it, I've spent too many hours today trying and all I've managed to come up with is this:

using System;
using System.IO;
using System.Runtime;
using System.Runtime.InteropServices;


namespace WinAmpTest
{
class WinAmpTest1
{
public static ActiveWinamp.MediaItem MI;
[STAThread]
public static void Main(string[] args)
{
string fname = @"c:\WATEST\ape.mp3";
ActiveWinamp.ApplicationClass WA = new ActiveWinamp.ApplicationClass();
MI = WA.LoadItem(ref fname);
WA.Play();
Console.Write(MI.Artist);
Console.WriteLine(WA.GetWaVersion());



// Keep App window open till enter pressed
Console.WriteLine("[Press Enter]");
Console.ReadLine();
}
}
}

All it does is start Winamp and plays the loaded track and displays a long of the version which appears to me to be meaningless. At the very least I had hoped it get the Track Artist but the MI object only contain a filename. I'm certain due my inept understanding and coding skills I'm missing some code but the docs are rather light right now and all the samples I've seen for VBScript are not helping me understand how to do it.

Ulitmately what I want to do is start Winamp and load an item into the playlist. not that hard really but I'm stumped.

Eaxactly what I want to do is be able to stuff data into the Shoutcast Source plug-in Title and URL metadata fields. the only way I've found programatically to do it so far is to load Winamp trigger a changestatus event and have the plugin detect it. If someone has complete scripts I can get hold of that show the whole picture for VBSCript I would be most appreciative. I've tried about 8 VBscript samples so far and just seem to be missing something.

Many thanks
Phil

vitalyb
4th September 2005, 21:04
Hey, you should use the WinAmp Library to get the id3 information:


Array m_MLResult = (Array)wo.MediaLibrary.RunQueryArray("(type == 0)");// AND ((lastplay >= [14 days ago]))");
int m_MLResult_iterator = m_MLResult.GetLowerBound(0);

while(m_MLResult_iterator <= m_MLResult.Length)
{
MediaItem CurrentItem = (MediaItem)m_MLResult.GetValue(m_MLResult_iterator);

Console.Writeline(CurrentItem.Artist);
m_MLResult_iterator++;
}



In the Query you can enter whatever file you need to find.

P.S Naturally you can use foreach to iterate the array instead of for.

Cadish
7th September 2005, 13:40
Hi,

Hi, I've a script to make a database from the playlist...
Set wa = CreateObject("ActiveWinamp.Application")

DataBase = "C:\Program Files\Winamp\MyMp3's.mdb"
Set fso = CreateObject("Scripting.FileSystemObject")
Set TS = fso.OpenTextFile("errors.log", 2, True)
Set Co = createobject("ADODB.Connection")
on error resume next
Co.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""" & DataBase & """;")
on error goto 0

If Co.State = 1 Then
req = "DELETE * FROM MP3"
Co.Execute req



for each song in wa.playlist
req = "INSERT INTO MP3 (Name,PathAndName,IsAFile,Artist,[Year],Genre) VALUES( """ & song.filename & """ ,

""" & song.filename & """ , """ & 1 & """ , """ & song.artist & """ , """ & song.ATFString("%year%") & """ ,

""" & song.genre & """ )"
Co.Execute req
next

End If
Co.close

MsgBox "Done"

How can I get the filename, not the path?

So e.g. for a file: "D:\Music\Elvis Presley - A Little Less Conversation.mp3"
I want "Elvis Presley - A Little Less Conversation.mp3"

And how can I get the folder of that song?

And how can I assign a hotkey to the whole script?

CaAl
8th September 2005, 16:20
I've written a couple of .vbs files that mimic pressing the play/pause, stop, backward, forward buttons, respectively.
The code for the forward button is as follows:


Set wo = CreateObject("ActiveWinamp.Application")
dim lastpos, curitem
curitem = wo.playlist.position
lastpos = wo.playlist.count
if not(curitem = lastpos) then
curitem = curitem + 1
wo.playlist.position = curitem
wo.play
end if


Quite straightforward - but not working good enough. When I put winamp on shuffle mode, forward goes to the next song in the queue instead of a random song.

Is there any way to check whether shuffle is on or off? (Or better even, is there an easier way to mimic the forward-button?)

vitalyb
8th September 2005, 21:21
Hey, you'll be better with using CLEveR (http://www.winamp.com/plugins/details.php?id=58602) (command line executables). It easily executes all the common operations.

shaneh
8th September 2005, 21:41
The application.skip method mimics the "forward" button. Otherwise, you can use CLEveR as vitalyb posted.

bdmagee
7th October 2005, 13:25
How do you access the WScript object and its methods from a script runing "inside" winamp?

More specifically, I need to run "wscript.sleep 1000" within a "startup_xxx.vbs" script. I get a message "Object Requred: Wscript". I tried "Set WScript = CreateObject("WSH.WScript").

bdmagee
7th October 2005, 21:52
I hacked the sleep function by executing another VBS script:
objShell.Run "WScript.exe Delay.vbs " & iSleep,, true


Someone please explain this to me...

This code works:
sPLFolder = "I:\Music - Playlists\"
sPlayList = "test.m3u"
Set objPlayList = objWinAmp.LoadItem(sPLFolder & sPlayList)

This gives me a type mismatch error on LoadItem:
sPLFolder = "I:\Music - Playlists\"
sPlayList = "test.m3u"
sFileName = sPLFolder & sPlayList
Set objPlayList = objWinAmp.LoadItem(sFileName)

shaneh
7th October 2005, 23:51
You cannot access the sleep method of wscript, as it is a host supplied method and not a method of the object. I have provided a settimeout method host method for AW however which can be used to sleep.

Both versions of your code work fine for me, although I am running it as an internal script rather than external, and so dont have the 'objWinamp.' bit. It is likely to be your host environment - which I assume is wscript or VB something. You could try declaring sFileName as a string, or setting it as sFileName = "" at first to make your host realise that it is a string, or try using the + operator instead of &.

bdmagee
9th October 2005, 17:32
Thank you for checking. The coding problem may be due to running v1.0. I recently found the v1.2 on the sourceforge cvs, so maybe that took care of it.

I saw the SetTImeOut method but wasn't quite sure about how it worked. The Sleep method of WScript has "DoEvents" functionality in VB. Does the SetTimeOut method allow the CPU to process other instuctions also?


Also, my startup script (which runs internally) has an indefinite do...loop (why I need to sleep between loops). I've noticed that when I exit winamp, although the window closes, the winamp.exe process stays in task manager. In fact, it causes windows pop-up the "ending program" dialog when logging off.

I tried to set a flag with the Application_ApplicationExited event that kicks out of the loop (Do until fExited:,,,:Loop), but the ApplicationExited event isn't triggering. I've tried several other events also, but no luck. However, the sample startup_log.vbs file does work.

bdmagee
9th October 2005, 20:35
Problem with Winamp hanging in process list was due to a flakey plug-in, not activewinamp script. Sorry about that folks.

dcyr
27th October 2005, 18:11
www.myplugins.info appears to be offline. Is there anywhere else I can find information/new versions?

shaneh
28th October 2005, 22:33
The site should be up again soon, you can find a bit of info at:

http://sourceforge.net/projects/activewinamp/

The updated version is in the CVS. You will need to browse around and find the "Release" and download the gen_activewa.dll file and copy it over.

mjcumming
15th November 2005, 15:01
Hi,

Does ActiveWinamp allow enumerating and playing back radiostations in the Media Library?

PNT
22nd December 2005, 00:43
Is it possible to view Internet radio stream information from this plugin? I have managed to display the ID3 tag info using VB script but I cannot seem to find any info regarding streams. When using title it shows stream number but not stream name or current title

Thunder Pussy
26th January 2006, 00:02
I did finally upload some things to the wiki a month or so ago.

Reading the 5.2 beta thread is worrying b/c it looks that activewinamp is going to be broken by the change to 'get playlist selection.' Somebody please tell me otherwise.

DrO
26th January 2006, 00:04
i'd assume shane uses the code he posted to get the selected playlist items so yes, it would be broken by the change. as is in the post i made at the start of the thread, it's simple to fix

-daz

Thunder Pussy
26th January 2006, 00:28
I read that & it's good to hear that it's simple to fix. I brought it to this thread b/c I noticed Shane hasn't posted in a while & wanted to show how I like activewinamp. Thanks for the info.

Best,

DrO
26th January 2006, 00:32
Since the activewinamp source is available in cvs then anyone could provide a patched version of the plugin. Yeah, there's been no posting in some time though i've noticed a certain name in the 'users browsing this forum' info...

-daz

shaneh
26th January 2006, 11:19
Yes I still come in and read the posts when I can. Though it takes a lot longer to reply than read, and I unfortuantly don't have time for support anymore. I have around 200 unanswered emails in my inbox, hundreds of things to do, and basically no time anymore to do it. Its quite depressing to think that if I were to try handle all of that, all my free time for the forseeable future would be consumed.

Nonetheless... I will try take a look at this stuff soon. I desperately need to get a new version of AW out, as the one in the CVS fixes a few things, though it too needs a few fixes. The method I used to get the selection seems to still work for now in the beta, but I will add support for the newer method for newer versions of Winamp. With these ATF changes I will need to update a few of my plugins anyway.

MarquisEXB
31st January 2006, 14:50
I wrote a script that will prompt for a year (inputbox) and change the mp3 tag (using id3co). Although the mp3 gets updated, the winamp ml keeps the previous year data.

I'm using a sendto: "for each track in x" and I've tried track.year=songyear, but I get an error. For the time being I'm running my script then using CTRL-E to update the ml. (I know you can update the mp3 tag with CTRL-E, but it's considerable slower - than even this method).

I have about 3000 songs without the year data in them & it's tedious enough to find the year data. I guess I could remove it from the database & re-add (I keep all my playcount & rating info in the mp3 tag), but again that's a bit tedious.

Is there anyway to update the ml from the file using a script?

MarquisEXB
31st January 2006, 14:52
Another question:

Is there a way to have a script run after a file has been played? This way I can update my mp3 tag with playcount & rating everytime an mp3 is played.

shaneh
1st February 2006, 10:11
As I explained in my email, the reason many fields are read only is because :

a. I havent got around to exposing them properly
b. I wasnt sure these fields should be made writeable anyway - ie filesize and time etc shouldnt really be modified. The file itself should be, and then the ml told to re-read the info. As AW doesnt modify file tags, I wasnt sure about the ml and id3 tag getting out of sync.
c. I would prefer to have the cached object modified, then issuing a 'update to ml' type function so that all the info would be updated in one update rather than one for each meta data item modified.

Currently, meta data is updated into the ml as the property is modified, which Im not a massive fan of, but it does simplify programming. I have updated the cvs version to expose year, length and track in this way. I will do bitrate,filetime and filesize etc later. I may possibly use a flag in the media item to switch between on-demand ml updates or not for better performance when needed.


There is a 'track change' event that you can hook for performing actions when a new song is played.

MarquisEXB
2nd February 2006, 02:46
Here's something I wrote yesterday. Not sure if it should get its own thread, but since it's a winamp script, I'll include it here.

You need to download AlbumArtAggregator, which you can get free online. I have the script download the file into the folder with the mp3, but have it named by the album cover. I added this to toaster "%dir%\\%album%.jpg;" because that way I can have multiple album covers in one directory.

It should be fairly easy to substitute the location of AAA.exe or the name of the image file downloaded. Save it as sendto_AAA.vbs in your WA scripts folder.

on error resume next

' This requires AlbumArtAggregator.exe
' You can find it at:
' http://team.thenexusnet.com/nexus/AAA/
'
' This program will look for album.jpg in
' the same folder the mp3 resides in.
' If the .jpg doesn't exist,
' this .vbs will use AlbumArtAggregator.exe
' to download a file into album.jpg

AAA = "C:\Program Files\AlbumArtGen\AlbumArtAggregator.exe"

Dim fso
set fso = CreateObject("Scripting.FileSystemObject")

vbq = chr(34) ' double quotes for later usage

x = GetSendToItems
if ubound(x,1) > 0 Then

dim AlbCompl ' This keeps track of what albums were done (so no repeats)

for each track in x
Set f = fso.GetFile(track.filename)
if instr(AlbCompl, f.ParentFolder & "\" & track.album & ".jpg") then
'An attempt was already made on this album
'msgbox "Done Before"
else
'add target filename to albcompl - so that we're not trying
'to get the same album more than once
AlbCompl=AlbCompl & f.ParentFolder & "\" & track.album & ".jpg" & vbcrlf

if fso.FileExists ( f.ParentFolder & "\" & track.album & ".jpg") then
'msgbox "Image exists: " & f.ParentFolder & "\" & track.album & ".jpg"
else
'msgbox "Image not found: " & f.ParentFolder & "\" & track.album & ".jpg"

'Run AAA to download the file
cRun vbq & AAA & vbq & " " & _
vbq & track.artist & " - " & track.album & vbq & _
" " & vbq & f.ParentFolder & "\" & track.album & ".jpg" & vbq
end if
' msgbox track.filename
end if
next
end if
msgbox "No. of jpegs attempted to download: " & ubound(split(AlbCompl,vbcrlf))
quit

private sub cRun(strcRun) 'subroutines to call AAA
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")

WSHShell.Run strcRun, 1, true
end sub

MarquisEXB
18th February 2006, 18:35
This script goes through every song in your playlist** and notes the artist. It then runs through & repopulates the playlist with the first song from each artist. Then it enqueues the second (if any) song from each artist, and so forth.

One application of this is if you want to listen to 10 or 20 different albums, but don't want to hear any song by the same artist twice in a row (until the very end). You may want to enqueue 20 albums from different artists & randomize it, because if not you'll hear every first song on the albums first, then all the second songs on each album, etc.

Another use for this is if you make a playlist with a few random collections, but you don't want to hear the same artist twice in a row.

** (I used x = playlist.getselection(), because I don't know how to get the entire playlist).

playlist_Dupe_Artist_Move

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Select **ALL** the songs in your playlist
'
' This will reorder it, taking any songs
' by duplicate artists & move them to the end.
'
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim x
x = playlist.getselection()
playlist.clear

Set Dict1 = CreateObject("Scripting.dictionary")
Dict1.CompareMode = BinaryCompare
i=1 ' i is the number of each treack

for each track in x
Dict1(ucase(track.artist))=Dict1(ucase(track.artist)) & vbcrlf & cstr(i)
i=i+1
next

i=0 ' now i represents the number of times to go through the array

do
EndLoop=TRUE
i=i+1

for each Songs in Dict1.Items

if ubound(split(songs,vbcrlf)) >= (i) then
EndLoop=FALSE
x(split(songs,vbcrlf)(i)).enqueue
end if

next 'for each Songs in Dict1.Items

' set sep = LoadItem("X:~~ " & i & " ~~~~~~~~~~~~~~")
' sep.insert(playlist.count)

loop until EndLoop or i > 100000 ' failsafe


quit

MarquisEXB
18th February 2006, 18:44
Oh and if you want a script that will give you X number of albums, without repeating the same artist, use this script.

You'll want to edit this section, it should be relatively self explanatory. The genres are comma seperated, and each one will give you Genre Begins 'XXX'. Year will give me a year between today & 1977.


genres=cSTR(InputBox("Genre(s) BEGINS with... ?","GENRES","alt,new,punk,lo,hip-r,ska"))
Randomize
ranYear = int(rnd()*datediff("yyyy", #01-01-1977#, now())) + 1977
years=cSTR(INputBox("Year? [ex: > 2000) -- or > 1995 AND Year < 2000]","YEAR","year >= " & ranYear))
ratings = cSTR(InputBox("Ratings?","Rating","rating > 1 "))
Extra=cSTR(INputBox("Extra? [ex: & (lastplay < [3 weeks ago] OR playcount < 1)","EXTRA","(lastplay < [3 weeks ago] OR playcount < 1)"))


playlist_1_Albums_Random.vbs


on error resume next
Randomize

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

TheQuery=getMLQquery("type=0 &! (album ISEMPTY)")
msgbox TheQuery

mlq = medialibrary.runqueryarray(TheQuery)

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

i = 0
AllAlbums="" ' string that contains all album names

for each track in mlq
if instr(AllAlbums,ucase(track.album)) = 0 then
i = i + 1
AllAlbums=AllAlbums&vbcrlf& ucase(track.album)
Dict1(ucase(track.artist))=Dict1(ucase(track.artist)) & vbcrlf & _
CStr(i) & asc(178) & ucase(track.album)
end if
next

itms = Dict1.Items
numArt=ubound(itms)+1

num = CInt(InputBox("Albums: " & i & vbcrlf & _
"Artists: " & numArt & vbcrlf & _
"Choose the # of albums","#","3"))

if numart>=num then

do while (tracks<num)

safe = 0

do
safe=safe+1
Randomize
RandArtist = Int(numArt*Rnd) ' This is the artist
loop until (safe > 10000) or (instr(AllArtists,RandArtist & ";")=0)

AllArtists=AllArtists & RandArtist & ";"
'msgbox AllArtists & vbcrlf & "-" & itms(rand)

arrSong = Split(itms(RandArtist ), vbcrlf)
Randomize
TheAlbum = split(arrSong(int(ubound(arrSong)*RND +1)),asc(178) )(1)

InsertAlbum theAlbum

tracks=tracks+1
Loop
else
msgbox "Too many songs"
end if

quit

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''' FUNCTIONS
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

function InsertAlbum(thealbum)

mlq2 = medialibrary.runqueryarray("album = """ + thealbum + """")
Set Dict2 = CreateObject("Scripting.dictionary")
Dict2.CompareMode = BinaryCompare

i = 0
min=1000000
max=0

' This section is to sort by track number.

for each song in mlq2
i=i+1
theTrack=song.track
Dict1(theTrack)=i
if theTrack<min then
min=theTrack
end if
if theTrack>Max then
max=theTrack
end if
next

for z= min to max
if len(dict1(z)) > 0 then
mlq2(dict1(z)).enqueue
end if
next 'z

set sep = LoadItem("X:-- " & thealbum & " (" & ubound(mlq2) & ") --------------------------")
sep.insert(playlist.count)

mlq2=""
end function

private function getMLQquery(strInitial)
' This asks the user some questions so that
' you can choose music as you see fit.

dim genres,years,ratings,extra

genres=cSTR(InputBox("Genre(s) BEGINS with... ?","GENRES","alt,new,punk,lo,hip-r,ska"))
Randomize
ranYear = int(rnd()*datediff("yyyy", #01-01-1977#, now())) + 1977
years=cSTR(INputBox("Year? [ex: > 2000) -- or > 1995 AND Year < 2000]","YEAR","year >= " & ranYear))
ratings = cSTR(InputBox("Ratings?","Rating","rating > 1 "))
Extra=cSTR(INputBox("Extra? [ex: & (lastplay < [3 weeks ago] OR playcount < 1)","EXTRA","(lastplay < [3 weeks ago] OR playcount < 1)"))

if len(extra) > 0 then
extra = " & (" & extra & ") "
end if

if len(ratings) > 0 then
ratings = " & (" & ratings & ") "
end if

if len(years) > 0 then
years = " & (" & years & ") "
end if

if len(genres) > 0 then

genre=split(genres,",")

if ubound(genre) >0 then
genreline="& ("
for each onegenre in genre
genreline=genreline & " genre begins """ & onegenre & """ OR "
next
genreline = genreline & " Genre begins "" QQQ "") "
else
genreline="& GENRE BEGINS """ + genre(0) +""""

end if
else
genreline=""
end if

GetMLQquery= strInitial &ratings & genreline & years &extra
end function

MarquisEXB
18th February 2006, 19:35
And for those that are too lazy to copy & paste...

shaneh
18th February 2006, 23:25
Ive added those scripts to : http://www.myplugins*******activewinamp/doku.php/examples:root

You and everyone else has access to add and edit entries on these pages.

Note, to get every item in your playlist, just use the playlist object. ie. msgbox playlist(1).artist

or

for each song in playlist
msgbox song.artist
next

Thunder Pussy
19th February 2006, 00:31
Neat albums script. Thanks, MarquisEXB

/edit Excellent albums script.

MarquisEXB
19th February 2006, 19:33
Originally posted by shaneh

Note, to get every item in your playlist, just use the playlist object. ie. msgbox playlist(1).artist

or

for each song in playlist
msgbox song.artist
next [/B]

I've modified the wiki site to reflect this.

Thanks for the code.

MarquisEXB
19th February 2006, 19:43
Question how would you know which is the next song, or the selected song in Winamp?

For example, I can randomize all the songs in the playlist, but I would like to put the currently playing or highlighted song as #1 in the playlist. How would I get this info from AW?

MarquisEXB
20th February 2006, 02:21
I'll answer my own question:

playlist.position

:)

MarquisEXB
26th February 2006, 22:58
Added script to wiki: delete duplicately titled songs.

This script will delete any songs with the same title from your playlist. Good if you make a playlist from multiple queries, have lots of compilations/greatest hits, cover songs, or live albums & don't want to hear the same song in different version.

http://www.myplugins*******activewinamp/doku.php/examples:playlist:remove_duplicately_titled_songs

Anyway it's on the wiki if the above link doesn't work.

http://www.myplugins*******activewinamp/doku.php/examples:root

heinz57g
27th February 2006, 19:23
could anybody confirm that the basic ACTIVEWINAMP is not working anymore in 5.20? upgraded this morning, and noticed
a while later that while the scriting menue still appeared, none of the functions (sort/random/whatever) had any effect at all.

i am a rather basic user, having just used the most easy setup to sort by track number and similar, so if there is a workaround or update, could somebody kindly put this in simple words and let me know?

or just confirm it is over with for the time being?

greetings - heinz -

MarquisEXB
27th February 2006, 21:38
The swapindex command seems to be broken. Not sure what else.

MarquisEXB
27th February 2006, 23:05
Hmm this is odd. I can run my playlist randomizer on the entire playlist. However if I run it with just the selected items (the default script that comes with AW) it doesn't work.

billyvnilly
1st March 2006, 03:23
@heinz
you can try downloading the latest version of AW. save the .dll file in dir\winamp\plugins. it should replace existing copy of gen_activewinamp.dll

CVS (http://cvs.sourceforge.net/viewcvs.py/activewinamp/activewinamp/Release/)

@marquis... hey I've noticed youve been doing some scripts and i wonder if you take requests. Take the ratings from the songs in playlist, and add song x number of times to the playlist. (songs rated 5 will appear a total of 5 times in the playlist) This should help weigh the songs with shuffle on.

MarquisEXB
1st March 2006, 03:57
Originally posted by billyvnilly
@marquis... hey I've noticed youve been doing some scripts and i wonder if you take requests. Take the ratings from the songs in playlist, and add song x number of times to the playlist. (songs rated 5 will appear a total of 5 times in the playlist) This should help weigh the songs with shuffle on.

for each track in playlist
if track.rating<>255 then
for x = 1 to track.rating-1
Tracks2Add=Tracks2Add & track.filename &vbcrlf
next
end if
next

'msgbox tracks2add

for each FileName in split(Tracks2Add,vbcrlf)
if len(filename) > 0 then
LoadItem(filename).enqueue
end if
next

MarquisEXB
1st March 2006, 04:05
Originally posted by billyvnilly
@heinz
you can try downloading the latest version of AW. save the .dll file in dir\winamp\plugins. it should replace existing copy of gen_activewinamp.dll


This is the .dll I've been using. I can't use ShaneH's reverse selection or randomize selection. It appears the track.position is broken. It returns '1236609' each time.

For example, highlight a few items in your playlist (not more than 5, unless you like hitting OK a lot), and run this script.

for each track in x
msgbox track.position
next
quit

billyvnilly
1st March 2006, 04:27
yeah, cool thanks a bunch. works as desired in 5.13

Ive confirmed activeWA doesnt work as you described as well in 5.2, and im positive ShaneH already knows its broke ;)

heinz57g
1st March 2006, 09:28
well, tks to all that chimed in, consensus seems to be even latest versions (which i have) dont work, right? at least i dont have to stay up all night scratching my head ...

there might be workarounds, but i am not firm enough to use them (yet). so i will wait for an update.

greetings - heinz -

shaneh
1st March 2006, 10:36
Yes, playlist.getselection() is probably broken in 5.2. Even if it isn't there is a better method in Winamp 5.2 which Ive added support for. The CVS has been updated.

Ticket:
https://sourceforge.net/tracker/index.php?func=detail&aid=1439978&group_id=132165&atid=723332

heinz57g
1st March 2006, 15:45
shaneh, pls bear with people who are not quite as 'fit' as you: what am i supposed to do now? download a new version (from where?) and install it over the old one?

greetings - heinz -

Lucky Luke
1st March 2006, 16:45
Hi, very nice plugin, but I have a problem when I try to create a instance of the playlist class in Visual Basic .NET 2005 express edition.

I've this piece of code:


Dim winamp As New ActiveWinamp.Application
Dim playlist As New ActiveWinamp.Playlist ' I get the error on this line


And this is the error:
Retrieving the COM class factory for component with CLSID {5108E2F5-A7E8-4284-9555-9FA8C3994B9C} failed due to the following error: 80040154.

But when I use this:

Dim winamp As New ActiveWinamp.Application

Private Sub LoadPlaylist()
Dim i As Integer
Dim total As Integer = winamp.Playlist.Count
Dim pct As Integer
lstPlaylist.Items.Clear()
For i = 0 To total - 1
lstPlaylist.Items.Add(winamp.Playlist.Item(i).ATFString("[%artist% - ]$if2(%title%,$filepart(%filename%))")) ' on this line I get the error

pct = ((i + 1) / total) * 100
Progressbar.Value = pct
Next

StatusText.Text = "Playlist Refreshed"
Progressbar.Value = 0
End Sub


I get this error:
Object reference not set to an instance of an object.

So i tried this:

Dim winamp As New ActiveWinamp.Application

Private Sub LoadPlaylist()
Dim i As Integer
Dim total As Integer = winamp.Playlist.Count
Dim pct As Integer
lstPlaylist.Items.Clear()
For i = 0 To total - 1
lstPlaylist.Items.Add(New winamp.Playlist.Item(i).ATFString("[%artist% - ]$if2(%title%,$filepart(%filename%))")) ' on this line I get the error

pct = ((i + 1) / total) * 100
Progressbar.Value = pct
Next

StatusText.Text = "Playlist Refreshed"
Progressbar.Value = 0
End Sub


But then I get the error:
Type 'winamp.Playlist.Item' is not defined.

Does anybody know how to fix this?

shaneh
1st March 2006, 20:57
@heinz57g:
Use the 'latest cvs version download' link on:

http://www.myplugins*******activewinamp/doku.php/activewinamp

and just copy it over your old version in your winamp plugins directoy. Note it may break a couple scripts, in particular ones that use the media library queries, as this has changed a little in this version. Generally all it should require is adding a '?' to the start of the query in most cases.

I will make a new interim release of ActiveWinamp pretty soon, seeing as it is broken for 5.2. I wanted to add a bunch more stuff before the next release but I think I will just push it out as a beta seeing as the one on the plugin page wouldnt work for a lot of people.

heinz57g
2nd March 2006, 10:50
shaney, tks alot. this worked as far as SORT/RAND goes, my main worries. and once i get into those scripts a bit deeper (AFTER your real 5.2 update), i am sure, you'll hear from me. meantime many tks for a great job well done.

greetings - heinz -

gerd.gabriel
9th March 2006, 20:54
Hi scripters,

I'm using a slightly modified version of the script to call Mp3Tag.

All functions well but informations YEAR and BITRATE disappear and PLAYCOUNT is set to the maximum possible unsigned integer value 4294967295 :-) :-(

Gerd

Script follows:

On Error Resume Next

Const ForReading = 1, ForWriting = 2

Dim fso, WshShell, TmpPlaylist, SendTo_Items
Dim TmpPlaylistPath, Mp3TagPath


Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")

'===== Get path where Mp3Tag is installed

Mp3TagPath = RegistryRead( _
"HKCU\Software\Moebius\Install\Mp3tag", "InstDir") & _
"\Mp3tag.exe"

'===== Get filename of temporary playlist

TmpPlaylistPath = GetEnvString("%TEMP%") & _
"\temp_mp3tag_playlist.m3u"

'===== Create tmp. playlist

Set TmpPlaylist = fso.OpenTextFile(TmpPlaylistPath, _
ForWriting, True)

'===== Get selected "Send To" items (either from
'===== MediaLibrary or from playlist)

SendTo_Items = GetSendToItems

'===== Write selection to tmp. playlist

TmpPlaylist.WriteLine ("#EXTM3U")

For Each track In SendTo_Items
TmpPlaylist.WriteLine (track.Filename)
Next

TmpPlaylist.Close

'===== Run Mp3tag and wait until it is finished

WshShell.Run """" & Mp3TagPath & """ ""/m3u:" & _
TmpPlaylistPath & """", 1, True

'===== Update entries in Media Library --> Errors in ML

For Each track In SendTo_Items
set theItem = LoadItem(track.filename)
MediaLibrary.Delete(theItem)
MediaLibrary.Insert(theItem)
next

'=== Have also tried MediaLibrary.RefreshMeta here.
'=== No difference.

Quit

gerd.gabriel
10th March 2006, 19:07
Aaaahhhh...

must use MediaLibrary.ADD (instead of INSERT).

shaneh
10th March 2006, 23:55
There isn't a MediaLibrary.Add function though??

Unfortuantly Winamp provides no means to just send a filename to the ML and have it read the info itself, you have to actually supply it. Which is what MediaLibrary::Insert attempts to do, but has some bugs.

I can see why playcount might be munged if there is no playcount for an item and you try to insert it. Although bitrate shouldnt have the problem and should just not be set - I will look at fixing it sometime.

When you run mp3tag, does it change the filenames?

For Each track In SendTo_Items
set theItem = LoadItem(track.filename)

If the filename changed the above wont work. Otherwise, it should be ok.

gerd.gabriel
11th March 2006, 15:13
Shaneh,

you are right... the "MediaLibrary.Add" is completely ignored by the interpreter (probably because of "ON ERROR RESUME NEXT" ?).

I now simply change the properties of theItem -- that's enough!

I havent't tried yet to INSERT a completely new entry (in case of changing filenames inside Mp3Tag) but will test it soon.

Regards and thanks for this wonderful tool
Gerd

CaboWaboAddict
22nd March 2006, 15:53
Originally posted by clatten
I am using Winamp 5.20 on a Win XP Home SP2 system.

The computer is new and then I installed winamp and activewinámp it won't find my aw scripts. Actually it won't fins any script at all.

Anyone else that encountered teh same problem?


Originally posted by shaneh
I will make a new interim release of ActiveWinamp pretty soon, seeing as it is broken for 5.2. I wanted to add a bunch more stuff before the next release but I think I will just push it out as a beta seeing as the one on the plugin page wouldnt work for a lot of people.

Seamore
25th March 2006, 21:54
Can I use ActiveWinamp from Delphi?

breakhead
26th March 2006, 14:23
just found this plugin, very nice!

whipped this up last night, will find and display nfos for all unique folders in selection, please excuse any bugs or bad code, very rusty on vb!


x = playlist.getselection

for i = 1 to ubound(x)
n = ""
d = split(x(i).filename,"\")
if ubound(d) > 0 Then
for s = 0 to ubound(d)-1
n = n + d(s) + "\"
next
end if
if n <> lastn then
set ofs = createobject("scripting.filesystemobject")
nf = locatefilebyext(n,"nfo")
if len(nf) > 0 then
txt = ofs.opentextfile(nf).readall
set ie = startIE()
ie.document.title = "NFO: " & nf
ie.document.body.style.backgroundColor = "black"
set pre = ie.document.createelement("PRE")
pre.innerText = txt
pre.style.color = "DADADA"
pre.style.fontSize = "10px"
ie.document.body.appendChild(pre)
ie.visible = true
ie.document.body.focus()
end if
lastn = n
end if
set ie = nothing
set nf = nothing
set ofs = nothing
next

function locateFileByExt(sFolder,sExt)
set d = ofs.GetFolder(sFolder)
for each f in d.files
name = f.name
aext = split(name,".")
if ubound(aext) <> -1 then ext = aext(ubound(aext))
if ucase(ext) = ucase(sExt) then locateFileByExt = f.path
next
set d = nothing
end function

function startIE()
set ie = createobject("internetexplorer.application")
ie.addressbar = false
ie.menubar = false
ie.resizable = false
ie.statusbar = false
ie.toolbar = false
ie.width = 535
ie.height = 550
ie.navigate("about:blank")
set startIE = ie
end function


oh and this quick one appends a cue file for the currently playing file at the end of the playlist (if u have a cue handler like ape cue it can then be expanded by playing it)


x = playlist.getselection

for i = 1 to ubound(x)
f = ""
a = split(x(i).filename,".")
if ubound(a) <> -1 then
a(ubound(a)) = "cue"
f = join(a,".")
set ofs = createobject("scripting.filesystemobject")
if ofs.FileExists(f) then loaditem(cstr(f)).enqueue
end if
next


is there a workaround for playlist.position because id like to be able to insert items immediately after the currently selection?

thanks again!


edit: sorry forgot to ask. i know u can create a fake playlist entry with "X:blah", are there any other playlist commands like this?

Thunder Pussy
26th March 2006, 15:58
Originally posted by breakhead
is there a workaround for playlist.position because id like to be able to insert items immediately after the currently selection?


I think I can answer one of your questions. For insert after current instead of enqueue, substitute
.insert(x(1).position) for .enqueue

breakhead
26th March 2006, 16:13
yeah i tried that but position as a result of getselection() always returns 1236129 - is it just my system or is there a bug in getselection()?

breakhead
26th March 2006, 17:13
whilst im in the mood, another quick one. displays all images in folders from selected items. little bug that if u have an item from folder1, then an item from folder2, then an item from folder1 again it will display folder1's images twice (as the view nfo script does) - have to shoot now so if u want to use it fix it yourself!


x = playlist.getselection

for i = 1 to ubound(x)
n = ""
d = split(x(i).filename,"\")
if ubound(d) > -1 Then
for s = 0 to ubound(d)-1
n = n + d(s) + "\"
next
end if
if n <> lastn then
set ofs = createobject("scripting.filesystemobject")
nf = locatefilesbyext(n,"jpg")
if ubound(nf) > 0 then
set ie = startIE(360,550)
ie.document.title = "IMAGES: " & n
ie.document.body.style.backgroundColor = "white"
ie.document.body.style.margin = 0
ie.document.body.style.textAlign = "center"
for each file in nf
if len(file) <> 0 then
set img = ie.document.createelement("IMG")
img.src = file
img.height = img.height / (img.width / 320)
img.width = 320
img.style.margin = 3
img.style.border = "1px dashed silver"
ie.document.body.appendChild(img)
end if
next
ie.visible = true
ie.document.body.focus()
end if
lastn = n
end if
set ie = nothing
set ofs = nothing
next

function locateFilesByExt(sFolder,sExt)
dim files
set d = ofs.GetFolder(sFolder)
for each f in d.files
name = f.name
aext = split(name,".")
if ubound(aext) <> -1 then ext = aext(ubound(aext))
if ucase(ext) = ucase(sExt) then files = files & f.path & vbCrLf
next
if len(files) <> 0 then
locateFilesByExt = split(left(files,len(files)-1),vbcrlf)
else
locateFilesByExt = array()
end if
set d = nothing
end function

function startIE(width,height)
set ie = createobject("internetexplorer.application")
ie.addressbar = false
ie.menubar = false
ie.resizable = false
ie.statusbar = false
ie.toolbar = false
ie.width = width
ie.height = height
ie.navigate("about:blank")
set startIE = ie
end function


features you might like to add:

filename display
open full size image
set image as folder.jpg
search on web for new art

some thoughts on activewinamp:

do these scripts carry on running to recieve events? how can i exit a script?

could do some real nice stuff with xmlhttprequest

osmosis
15th April 2006, 14:00
hi i need some stupid newbie help. i'm trying to make this script (http://forums.winamp.com/showthread.php?postid=1676079#post1676079) work all the time without any user interaction other thatn playing the "trigger." so i've got it named startup_Party Shuffle.vbs and it's in the Scripts folder and all that, but it only works the first time after Winamp's started.. I assume this is because it IS a "startup" script. I have little-to-no scripting knowledge but i tried doing a do while loop for the whole script.. that just gave me CPU 100%. so what do i need to modify to make it do what i want (work correctly ANY time the trigger is played, not just the first)?

shaneh
15th April 2006, 23:30
@breakhead: getselection is broken for the latest versions of Winamp. Be sure to use the .dll from the CVS for the fixes to this and other problems. You can, and should, exit a script with 'Quit'. You can see the running scripts through the preferences window of the plugin.

@osmosis:
Sub Application_ChangedTrack

is an event function, it gets called everytime the track changes. You have the script run at startup, and by having this event function, AW will automatically call your function every time the track changes. Call 'quit' to exit the script.

Alternatively, you can have a 'script:/' entry in your playlist, which will actually call a script file when winamp gets to it in your playlist, which is probably a better solution.

osmosis
16th April 2006, 04:55
Thanks for the help shaneh! now i'm hoping for some more hehe. This has all inspired me to try and make the Party Shuffle script closer in it's functionality to that of iTunes. I believe i've done so but i've got some questions/roadblocks.

playlist_Party Shuffle.vbs
' +--------------------------------------------+
' | Party Shuffle 2.0 (15 track version) |
' +--------------------------------------------+
' Automatically enqueues a new song each time a song is played.
' Brought to you by neFAST and osmosis.

' Changes: 1) Starts with correct # tracks (builds the backlog as it goes, as per iTunes).
' 2) Maintains total # on track change (deleting and/or skipping one or more tracks).

' Todo: 1) Make the ML query music only.
' 2) Weighted shuffling.
' 3) Change color of backlogged tracks.

Dim mlq,mlq2,artist,pos,pchg
Randomize

' "smart" random slightly faster with big libraries
mlq = medialibrary.runqueryarray("type = 0 and trackno = 1")

' This is the first launch
' We clear the PL and add 10 songs
playlist.clear
do while (playlist.count<=9)
Rand = Int(ubound(mlq)*Rnd+1)
mlq2 = medialibrary.runqueryarray("artist = """ + mlq(Rand).artist + """")
Rand2 = Int(ubound(mlq2)*Rnd+1)
mlq2(Rand2).enqueue
Loop

' Now let's play
play

Sub Application_ChangedTrack

if playlist.position>6 then
' We delete however many the PL position has changed by
pos=playlist.position-6
pchg=0
do while (pos>pchg)
playlist.deleteindex(1)
pchg=pchg+1
Loop

end if

if playlist.count<=(playlist.position+8) then
' We add songs until there's a backlog of 5 (startup)
' or until we've reached 15 again
do while (playlist.count<=(playlist.position+8))
Rand = Int(ubound(mlq)*Rnd+1)
mlq2 = medialibrary.runqueryarray("artist = """ + mlq(Rand).artist + """")
Rand2 = Int(ubound(mlq2)*Rnd+1)
mlq2(Rand2).enqueue
Loop

end if

End Sub

First, about my todo list, I read your post on weighted shuffling earlier in the thread, so skip #2, but I was wondering if you could help me with #1 and was wondering if #3 was possible (i'd like to do it, if so, but if not, i don't care since it's only for asthetics).

Second, the big problem. I like being able to trigger Party Shuffling from the Script menu, this loads the script and the script needs to stay loaded for the ChangedTrack event to trigger. But that's a problem because that means there's nothing to quit the script and turn off Party Shuffle. any ideas?

thanks so much for the plugin and i'm greatful for any help you can provide.

osmosis
16th April 2006, 16:45
also i'd like to be able to take the file info from the ML instead of winamp having to load it in itself, because that seems to slow down the enqueuing a fair bit. i know there's a winamp option that makes it take info from the ML whenever possible, but is there a way to hardcode it into the script so that if it's not on it'll still be fast for those that don't enable that option?

osmosis
18th April 2006, 06:51
forget about the color, i know it's impossible and was a stupid question. and i figured out how to make sure it was only music; i guess neFAST must have forgot to include a type=0 in the final query that enqueues the files. also forget the above posted problem on meta data. i understand now that AW already uses the ML item data, and though it still seems a bit slow, i guess that's Winamp's fault?

i still need help with being able to stop the script. I'm hoping for a solution that won't cause the script to stop being self-contained. is there a way to place a trigger in the Scripts menu? the trigger could set a value that everything else could hinge on. that way i could make it a startup script; this would probably be ideal. another solution i imagined was if there were an event that could be triggered by clearing the playlist. so when someone didn't want to party shuffle anymore they could simply clear the playlist and the script would quit. it's fairly intuitive and would allow the script to remain a playlist script. it's not an overly common PL editor event so perhaps it could be worked in? another option is stoping it from another script. it seems odd to me to be able to call scripts but not terminate them from another. also i'd like to suggest that the script:// playlist item have an "endscript://" counterpart.

one last thing i'd like to know is if anyone can think of a better way to narrow down a query to only single instances of artists. this would make randomizing based on artist easier. neFAST's method involved only artists with trackno = 1, but naturally, not all artists in a song library will have a track 1.

shaneh
19th April 2006, 00:05
@osmosis:
Yes stopping scripts is a bit of a pain, you can terminate a script from the ActiveWinamp preferences window which lists running scripts. Alternatively, you can hook the end of playback / stop event and quit then. But I do intend to have a sub menu which lists the running scripts so you can terminate them easily, or something like that.

ActiveWinamp should automatically take the info from the ML if it is available, and will load the ML if it isn't loaded.

The reason your script is slow is because you are doing a ML query in a loop. ML queries are very slow. You are better off doing one query, and loading everything you need into a dictionary and index out of that. There are a few examples floating around using the dictionary object. You can then do a query of "" and get all items in your ML, and just load the dictionary object using the artist as an index. Theres a few examples of this on the AW wiki.

The runquery stuff has changed a bit from the version on the plugin page and the version in the CVS. The one in the CVS does a keyword search by default, the one on the plugin page does a query search. To do a query search in the CVS version just prefix '?' to the query.

osmosis
19th April 2006, 00:20
hmm i believe i'm using the one from the CVS (1.0.0.1?) but when i prefix my queries with ? i get a "Rand out of bounds" error.

is that a no to my playlist event proposal? hehe

shaneh
19th April 2006, 00:37
I dont think Winamp has a 'playlist cleared' event notification. You can hook buttons and what not, but thats a pretty crap way to do things. The truth is, Winamps API model is pretty shit.

I didnt want to add too many events and script management stuff, 'cause its not really a good idea to hook events with script. I dont recommend using scripts that run in the background, I dont think its quite robust or efficient enough for that. AW is really just intended to automate simple tasks like fixing up ratings and playcounts in your media library, generating pretty HTML playlist files, exporting/importing data around, enqueing a list of files from a txt file stored on a ftp site, downloading cover art, creating playlists based on stats in the ml, out of process access to Winamp and the ML etc. Just mainly to automate and easily customise things that run through once, instead of having to write lots of little plugins that perform really simple functions.

Some things are difficult to do in Winamp even with a stand alone plugin. Working with events, shuffling, playlist order overriding etc, cannot be done very elegantly in Winamp, with or without AW.

alexrussell
1st May 2006, 05:10
I recently updated my version of Winamp (it popped up a nice "you should probably update me now" message box upon startup so I went for it) to version 5.21 (x86) (and I use classic mode if that makes a difference).

Previously I had a script that basically submitted my artist and track data to my website for an "I'm listening to..." effect. I had the script in a file called startup_listento.vbs and AWA tells me it's loaded. However since this update (around the 8th of April) my script's Application_ChangedTrack event no longer fires.

So this post is just to ask whether this is just me or whether it's the new version of Winamp.


My script is basically this:

Dim artist, title
const url = "[my website]"
const blogname = "[my blogname]"
const password = "[my password]"

Sub Application_ChangedTrack
Dim mi
Set mi = playlist(playlist.position)
artist = deSpecial(mi.ATFString("%artist%"))
title = deSpecial(mi.ATFString("%title%"))

SendStats(url + "?blogname=" + blogname + "&password=" + password + "&artist=" + artist + "&title=" + title)
End Sub

Sub SendStats(url)
On Error Resume Next

Dim oXH
Set oXH = CreateObject("MSXML2.XMLHTTP")
oXH.Open "GET", url, True
oXH.Send
Set oXH = Nothing
End Sub

Function deSpecial(text)
deSpecial = text

deSpecial = replace(deSpecial, "?", "%3F")
deSpecial = replace(deSpecial, "=", "%3D")
deSpecial = replace(deSpecial, " ", "%20")
deSpecial = replace(deSpecial, "(", "%28")
deSpecial = replace(deSpecial, ")", "%29")
deSpecial = replace(deSpecial, "&", "%26")
deSpecial = replace(deSpecial, "@", "%40")
End Function


Thanks for any info you can give me.

osmosis
10th May 2006, 21:51
alexrussell: get the newest CVS revision of gen_activewa.dll from the sourceforge page and see if that fixes your problem. I've had no trouble with the ChangedTrack event.

anyone: since i have pretty much no knowledge of scripting and i just scrapped/hacked this together out of a couple other scripts with some minor ingenuity of my own, i was hoping that someone could look at my script and see if everything makes sense. please and thank you in advance to anyone who's willing.

playlist_Party Shuffle (15).vbs:
' +--------------------------------------------+
' | Party Shuffle 2.0 (15 track version) |
' +--------------------------------------------+
' Automatically enqueues a new random song each time another is played.
' An ActiveWinamp script brought to you by osmosis and neFAST.

' Changes: 1) Can be triggered via the Script menu.
' 2) Start with base # of current items (builds the backlog as it goes, as per iTunes).
' 3) On track change, maintains PL item total if any have been removed, skipped, etc.
' (note: iTunes updated automatically on remove but AW has no support for PL events).
' 4) Randomization now includes all artists.
' 5) Playlist now definitely contains only audio items.
' 6) Dialog on launch to choose whether to clear the playlist.
' 7) Script quits when playback is completely stopped.
' 8) Switched to a Scripting Dictionary for faster querying and randomized loading.

' Todo: 1) Weighted shuffling (in 3.0).

' May 10, 2006

Dim mlq,i,j,Dict1,keys,startup,idxs,pos,pchg

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

' This is the first launch
startup=MsgBox("Start new Party Shuffle playlist?",_
vbYesNoCancel+vbDefaultButton2+vbQuestion,"Winamp Party Shuffle")

if startup=2 then
' abort if requested
quit
end if

' clear PL if desired
if startup=6 then
playlist.clear
end if

' more inclusive.
mlq = MediaLibrary.RunQueryArray("type=0")
i = 0

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

Randomize
itms = Dict1.Items

' fill the PL if needed (up to 10, any others will be added on track change)
Do while (playlist.count<=9)
Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
mlq(Rand2).enqueue
Loop

if startup=6 then
' Now let's play
play
end if

Sub Application_ChangedTrack

if playlist.position>6 then
' We delete however many the PL position has changed by
pos=playlist.position-6
pchg=0
Do while (pos>pchg)
playlist.deleteindex(1)
pchg=pchg+1
Loop

end if

if playlist.count<=(playlist.position+8) then
' We add songs until there's a backlog of 5 (startup)
' or until we've reached 15 again
Do while (playlist.count<=(playlist.position+8))
Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
mlq(Rand2).enqueue
Loop

end if

End Sub

Sub Application_ChangedStatus

if PlayState=0 then
' exit if state has changed to stopped
quit
end if

End Sub

:D

alexrussell
11th May 2006, 15:58
I forgot to mention that I tried getting the latest CVS version. Well hopefully Winamp will have a new version out soon that I can download, and it'll fix the problem.

Thanks for your help anyway.



A little addendum, though, is that you shouldn't try to analyse my script. Just a simple script with a single 'MsgBox "Hi!"' statement doesn't work if in Application_ChangedTrack.

That is to say, if I have a script called blah.vbs [Edit: I mean playlist_blah.vbs] that contains exactly one line:

MsgBox "Hi!"

I can run that from the right-click menu perfectly. If I change it to:

Sub Application_ChangedTrack
MsgBox "Hi!"
End Sub

and name it startup_blah.vbs, it no longer works.

osmosis
11th May 2006, 16:37
hmm it might be the CVS, when i was testing out neFAST's old party shuffle it worked the first time i gave the trigger to it (which was an ChangedTrack event).. but it would only work the first time it saw it, even if i stopped it and tried to trigger it again. and didn't work until i restarted winamp (if i recall correctly). so maybe there is a problem with changedtrack and startup scripts. if the functionality of your script depends on a newer AW, then get the newest, if not, try downgrading, i thought the only thing that was broken in the upgrade to 5.2 was playlist.getselection.

here's the newest CVS that i've been able to get, SF's web CVS browsing seems whacked lately.

alexrussell
11th May 2006, 17:04
No, that version (which seems to be the same version I had if the 'file version' tag is anything to go by) didn't do it either. And it started going wrong with the latest stable (version 1.0) after I upgraded. THEN I upgraded AW to 1.0.0.1 (CVS) and it still didn't work.

Having said that, it actually kinda works every now and again with random intervals. And it's not specific songs (like I thought) as I play that song again and it doesn't work.

I upgraded Winamp on 8th April and that's when it stopped working. However since then it's logged three songs. Two were very close (25 mins apart) on 29th April, and one just a few minutes ago. These two instances (and three songs) were probably logged with the CVS 1.0.0.1 version, rather than the old 1.0 version, although I'm starting to think that makes no difference.

I'm very confused. Obviously the event is firing every now and again, but literally DAYS apart, and I play many songs a day.

It's got me very stumped. I wonder if I can downgrade Winamp without it doing any damage...


Edit: also just in case you were wondering (and I may have mentioned it in my first post but I don't remember) the script IS showing up in the "currently running scripts" section if run as a startup script. So the script IS being executed, just not very often.

osmosis
11th May 2006, 17:08
if you changed it to a playlist script and just left it resident, it would probably work. you could have a startup script that triggers it as a playlist script so it's further automated.

alexrussell
11th May 2006, 17:12
Sorry, I don't quite understand. How do I got about doing that?

osmosis
11th May 2006, 17:14
rename the script to playlist_listento.vbs

then restart winamp and you can run it from the Scripts menu in the playlist.

you could also make a startup_ltstart.vbs that called the playlist_listento.vbs. i don't recall what the function is to call another script but it should be on the wiki. that would automate it again so you wouldn't have to run anything.

alexrussell
11th May 2006, 17:23
Renaming it to playlist_listento.vbs and running it manually does nothing. It doesn't add it to the "currently running scripts" box. Is there something else I have to do?

osmosis
11th May 2006, 17:30
yeah, that means it's loaded. it has to be loaded before it'll work. so it doesn't work on track change when it's running as a playlist? that's all i had for ideas since i haven't run into any trouble with changedtrack in a playlist script, only in startup scripts. sorry.

alexrussell
11th May 2006, 17:44
Not being added to the "currently running scripts" box means it's loaded? Did you just read my reply incorrectly or am I not getting something?

Sorry I'm being a bit of pain with this, and thanks for all your help.

Go through again how to make it a playlist thingy?


Here's what I did:

1) Rename to playlist_listento.vbs
2) Reload Winamp
3) Yay! It's on the scripts menu
4) Click it
5) Nothing happens. Songs aren't logged, nothing appears in the "currently running scripts" box in the AW UI. Nothing at all.

Remedy?

osmosis
11th May 2006, 17:59
ohhh, sorry, i did read it incorrectly. i thought you said it WAS loaded. okay. sounds like your script is quitting itself for some reason i can't figure out from looking at it. that's my best guess at the problem.. no idea what the remedy is.

alexrussell
12th May 2006, 14:53
Well thanks for trying :) I suppose I'll have to just mess around with it. In a way I'm glad it's only my version (i.e. that AW isn't broken) but in a way I'm not. If AW was broken, it's more likely to be fixed (because it looks doubtful I can fix it myself).

Oh well. These things happen.

mikkokh
13th May 2006, 11:35
Hi.

Seems that Winamp does not get my commands from Boot Script on boot time...
Script (VBS) is tested manualy from ActiveWinamp on Winamp running manualy and it works then, but i think that Winamp has not ready to get any commands so early boot time.

So, how i delay script on boot so log that Winamp is fully ready to complete actions?

Thanks.

osmosis
13th May 2006, 16:16
there are timers with which you can delay. not sure if there's an example on the wiki, but there's definitely mention of it in the out-of-date reference guide.

osmosis
17th May 2006, 22:52
we need some sort of bat signal for knowledgable coders.. citizens are in need!

neFAST
18th May 2006, 18:20
Hi folks. Funny to see that the party shuffle is still an issue at stake.
BTW I found the old "Rnd-bug" in the last version.
Here is a clean one with also a "weightening" attempt :P

' +--------------------------------------------+
' | Party Shuffle 2.0 (15 track version) |
' +--------------------------------------------+
' Automatically enqueues a new random song each time another is played.
' An ActiveWinamp script brought to you by osmosis and neFAST.

' Changes: 1) Can be triggered via the Script menu.
' 2) Start with base # of current items (builds the backlog as it goes, as per iTunes).
' 3) On track change, maintains PL item total if any have been removed, skipped, etc.
' (note: iTunes updated automatically on remove but AW has no support for PL events).
' 4) Randomization now includes all artists.
' 5) Playlist now definitely contains only audio items.
' 6) Dialog on launch to choose whether to clear the playlist.
' 7) Script quits when playback is completely stopped.
' 8) Switched to a Scripting Dictionary for faster querying and randomized loading.

' Todo: 1) Weighted shuffling (in 3.0).

' May 10, 2006

Dim mlq,i,j,Dict1,keys,startup,idxs,pos,pchg

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

' This is the first launch
startup=MsgBox("Start new Party Shuffle playlist?",_
vbYesNoCancel+vbDefaultButton2+vbQuestion,"Winamp Party Shuffle")

if startup=2 then
' abort if requested
quit
end if

' clear PL if desired
if startup=6 then
playlist.clear
end if

' more inclusive.
mlq = MediaLibrary.RunQueryArray("type=0")
i = 0

For each track in mlq
' rating weight (you may want to change the 3 coeff)
weight = 0
Do while (weight<=track.rating*3)
Dict1(track.artist)=Dict1(track.artist) + ":" + CStr(i)
weight = weight + 1
Loop
i = i + 1
next

Randomize
itms = Dict1.Items

' fill the PL if needed (up to 10, any others will be added on track change)
Do while (playlist.count<=9)
Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)*Rnd+1)))
mlq(Rand2).enqueue
Loop

if startup=6 then
' Now let's play
play
end if

Sub Application_ChangedTrack

if playlist.position>6 then
' We delete however many the PL position has changed by
pos=playlist.position-6
pchg=0
Do while (pos>pchg)
playlist.deleteindex(1)
pchg=pchg+1
Loop

end if

if playlist.count<=(playlist.position+8) then
' We add songs until there's a backlog of 5 (startup)
' or until we've reached 15 again
Do while (playlist.count<=(playlist.position+8))
Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
mlq(Rand2).enqueue
Loop

end if

End Sub

Sub Application_ChangedStatus

if PlayState=0 then
' exit if state has changed to stopped
quit
end if

End Sub

osmosis
19th May 2006, 20:02
ahh.. so it IS Rnd+1 and not +1 * Rnd. i'm assuming it should be so for both of them (you only fixed the initial playlist one). not sure it's quite ready for weighting since the randomization may not be random enough yet (i'll see if your +1 edit fixes it), but i'll let you know how it goes when i get around to testing it. also, thank you so much for coming around and checking the script through.

neFAST
19th May 2006, 20:10
Originally posted by osmosis
i'm assuming it should be so for both of them (you only fixed the initial playlist one).
Oops. My mistake
What's your problem with randomisation ?

osmosis
19th May 2006, 20:13
in a 9000+ song library, i shouldn't hear repeats. there is still a fair bit of random content thrown in but i am getting a lot of the same songs over again it seems. someone i know who's good with this stuff suggested that a good way to fix it would be to supply an argument to Randomize to make it better.. something involving date + time turned into a number because the same date and time never occurs twice was his suggestion, haven't tried it out yet. i'll see if the +1 movement helps it.

neFAST
19th May 2006, 20:33
You think that VB's random is so shitty ?

osmosis
19th May 2006, 20:42
it's not really about think, i have no preconceived notions about VB. i'm just basing this off what i've seen - or heard, rather - and i'm hearing a lot of the same songs when i shouldn't be. Randomize should be random, if it isn't random enough then it'll have to be improved.

neFAST
19th May 2006, 20:47
I suggest we should test it with the 2 fixes we found.

osmosis
19th May 2006, 20:48
yup, that's what i was proposing as well. :)

osmosis
21st May 2006, 00:16
alright. after testing for the last few hours, the randomization seems a lot better given the fixes.. however, there is still a slight tendency toward certain songs. i think we should try the randomization when supplied with a unique number (date & time) for an argument and see if it helps it. just means we have to make the Randomize trigger every time files are added to the playlist (instead of just the once at the beginning), and figure out how to format the date as only numbers.


.. unless the argument supplied is evaluated every time Rnd is used.. then it could just be an identifier/variable.. and in that case you'd still only have to trigger Randomize once.. not sure how it works in VB.

neFAST
21st May 2006, 05:24
after one day of testing, the random seems pretty good with my library (20000+ songs) but the rating weight is invisible... :)
I don't think a date-based random would change anything cause you'll never get truly random values.

osmosis
21st May 2006, 05:37
hmm. well, a date-based randomize would make it truely random since the same date and time never occur twice..

as for the testing, i don't know why with 20000 it would function any differently than it does with 9000 (maybe it has something to do with a central tendancy, and with a larger library the centre is a lot broader) but with 9000 i'm getting the same song(s) several times within an hour.

to recreate what i'm seeing, all you have to do is press the next button for awhile, watch the songs as they go by.. by doing this i see the same songs coming up occasionally.. so, i don't know what to tell you.

if you heard even the same song more than once in your day of testing, then the random isn't very good, since 20000 songs translates to about 60+ days of music. meaning idealy you wouldn't hear a song again until 60(ish) days after it is played.

MarquisEXB
25th May 2006, 04:35
If you want to make sure you don't hear the same songs over & over - you can try 1 of 2 things. The first is to add a lastplay < [3 weeks ago] in your query.

The second is to track the songs you enqueue. For example:


Do while (playlist.count<=9)
Safety=0
Do
Safety=Safety+1
Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)*Rnd+1)))
loop until (instr(EnqHistory,Rand2 & ":")=0) OR Safety > 10000
mlq(Rand2).enqueue
EnqHistory = EnqHistory & Rand2 & ":"
Loop

neFAST
27th May 2006, 01:38
Just a word to say that I reverted back to my "tracknumber=1" code, it's 10 times faster and Winamp jump form 33Mb to 40Mb instead of 100Mb of RAM ...
I have only complete and tagged cds in my library so it's working exactly as the "full random script" for me. Maybe there's another trick for people with dirty libraries :)

osmosis
27th May 2006, 02:49
i resent you calling my library dirty :p
a full random by rights would weight towards artists with more tracks, where yours would only weigh towards artists with more track 1's.. but yeah, that'd work for you. i, on the other hand, only keep songs i like, though i usually start out with proper full CDs. unfortunately some artists never make a good first song on an album hehe :)

as far as memory usage, mine only balloons to 37mb of RAM and 62 VM, so it's not such an issue with me. obviously, library size must be an important factor. i've been trying to figure out another way to make it fast, but nothing occurred to me. the scripting dictionary made the track to track operation A LOT smoother and speedy, but the hangtime on load does leave a bit to be desired. at least that hang doesn't happen every time you skip ahead by more than 4 tracks like it used to.. AND the memory ballooning only occurs on start-up and not every time the track changes.

neFAST have you tried anything Marquis mentioned above about avoiding repeats, or made any more progress with your rate weighting scheme? i haven't had the time to play around with any of it yet.

edit: also, i'm happy to report that after playing for 30 minutes or so, the 37mb RAM dropped to like 6mb RAM, and the 62 has only increased to around 65 so maybe it's not so bad since it yields it back up later.

gonemad
28th May 2006, 22:50
seems like 5.22 broke a few of the things in activewinamp (and toaster).. i noticed rating and playcount show up as nothing for both plugins.. im assuming this is due to the fact that the ML was broken up until multiple dlls... can anyone else verify this?

shaneh
28th May 2006, 23:21
Yes Ive noticed that too. I will take a look into it.

osmosis
29th May 2006, 00:32
hmm, i've started getting Rand out of bounds errors with my script. i hadn't made the correlation with upgrading but that must be it.

shaneh
12th June 2006, 02:30
Ive now corrected the ML meta data issue in the CVS version. I will probably make a new release soon, as the version in the winamp db is broken in several ways.

osmosis
12th June 2006, 16:55
good news :D

gonemad
21st June 2006, 03:48
is there any chance you could allow write access to the filename? i remember you discussing it earlier on in this thread.. i got this vb prog i wrote awhile back to let me archive my newer albums while still keeping ratings/playcount and all that.... but for that to work i relied on a plugin that exported the ML into an xml file.. which doesnt work anymore with the latest winamp

since i was pretty familiar with activewinamp i decided to try updating the ML with it... everything is coded.. but since it doesnt allow me to change the filename... it obviously doesnt work...

so is there any way you could put in a feature to change the filename of a mediaitem... or if its not complicated i could just modify the source myself... i just really couldnt find where

thanks for any help in advance

shaneh
21st June 2006, 04:04
I'm not sure if thats such a good idea, but I will take a look. I think there may have been issues with doing this but I can't really recall.

However, you can just do something like:

set miold = LoadItem("c:\oldfile.mp3")
set minew = LoadItem("c:\newfile.mp3)

'minew.clonefrom(miold)
minew.rating = miold.rating
minew.title = miold.title
'etc

Unfortuantly I don't think you can actually 'add' the new file, but if it already exists in your ml db then it should be ok.

Yes I agree something needs to be done here, but Im just not sure the best way to go about it.

gonemad
21st June 2006, 14:22
yea i know there would be a bunch of potential problems with it.. if not used properly

but yea if there was a way to actually add new mediaitems.. that would also work

the algorithm im trying to use is simply

move the folder to new destination and then
"edit" the ML and replace the old location with the new location

if i was able to add a new mediaitem to the ML... i'd probably could do something like

set whatever = LoadItem("c:\file.mp3")
whatever.filename = newfilename
AddItem(whatever)

then i would run delete missing files in the ML manually to clear the old stuff

ur idea would work fine if the files were actually in the ML already.. but as you know when u move a folder... the new location isnt present in the ML :/

shaneh
21st June 2006, 21:51
Yes but you can scan for new files from the ML, just dont run the remove missing files option. This will add all your new files, effectively having dupes. Then you run your update meta data script, then you run the remove missing files function.

gonemad
22nd June 2006, 15:12
i guess that could work.. i'd have to store all the destination info for the folders i moved.. plus all the properties of each song... then rescan.... search for the destinations and update all the info

but..i'd have to rescan my whole archive(currently i only rescan my new/incoming folder)...and one problem i noticed was when i rescan the library.. any of the custom genres that i put into the ML (ie instead of Metal i'll use Metalcore for some stuff).. but on rescan all of it goes back to metal... is there any way around that? since metalcore isnt a genre allowed to be stored in an mp3 i cant really write it to the file

MonteCarloPearl
22nd June 2006, 23:04
Hello all. Let me start off by saying I have spent the last 2 days looking through this entire thread and am quite impressed with what’s going on here. It seems this is the answer to my prayers. Unfortunately I know nothing about writing scripts so your help is VERY much appreciated on this. I believe the Party Shuffle script from NeFast/Osmosis will do most of what I want, it just needs some additions for what I need it to do.

Here’s my situation: I have Music videos in MPEG2 format not mp3s. (I think changing the Type=1 will fix that) I also have various movie clips in the same format. I need to show a few videos (some random number between 3 and 8) then show a movie clip then some more videos (Some random number between 3 and 8) then a movie clip etc.

Now here’s where it gets interesting. When the system goes to show a movie clip I need the computer to send some commands to a video switcher. When the movie clip is done I need to send commands to the video switcher again. The commands for the video switcher are already scripted and titled “OnetoAll” and “OnetoOne”. When its all done the sequence of events is music videos (3 to 8 of them), send OnetoAll script to switcher, then a single randomly chosen movie clip played, then send OnetoOne to switcher, then 3 to 8 music videos, OnetoAll, MovieClip, OnetoOne, 3-8 videos etc. The switcher scripts need to be sent every time a movie clip is played and allows the clip to be seen on all the LCDs throughout the bar then when the clip is over the LCDs go back to what they were showing before the clip. Videos/clips should only be allowed to play once every 12 hours.

Heres another feature (problem) needing a solution: The music videos are divided into 3 groups and stored in 3 separate folders on the D: drive. Those in group1 are shown up till 10PM those in group2 are shown 10pm to midnight and those in group3 are shown midnight to close. Is there a way to randomly pick videos from each folder group based on what time it is? Based on what I have read I don’t think you can chose from a folder perspective but rather only from the MediaList. If this is the case I imagine I can somehow tag each video with a group1, 2 or 3 designation and select them that way. Some guidance to aid my understanding please.

I am running v5.21 of Winamp and am trying to download the latest CVS version of AW but cant seem to get to the website. I have a WindowsXP sp2 machine. Thanks again in advance for help with this and sorry about the length I just wanted to be thorough.

gonemad
23rd June 2006, 01:04
having it pick songs from a certain folder depending on the time sounds pretty feasable.. if you had everything loaded in the playlist.. when the party shuffle goes to pick a video/song or whatever.. u can check the filename property and see what folder it is in.. if its not in the folder u want to be playing from... skip to another video/song

MonteCarloPearl
23rd June 2006, 18:28
I can see a loop with conditions to check that. Since the party shuffle script keeps videos queued in the playlist that would give time for the loop to run through several times even if it kept choosing the wrong videos. We are only talking about 700 music videos and about 100 movie clips. Even the shortest video is over 3 minutes so that gives several thousand opportunities to find and load a valid and correct video. Also, in getting 3-8 videos I imagine generating a random number between 3 and 8 then using that number to determine how many videos to load. After that, run through the movie clip process of sending the switcher script, queueing a movie clip, sending the next switcher script then go back to the top again. If the videos are stopped then quit. I can envision the logic and flow but do not know what to type for the script. This is where I need the expertise of the forum members.

MonteCarloPearl
23rd June 2006, 18:41
Is anyone else having trouble getting the latest CVS version? I am using this :

http://cvs.sourceforge.net/viewcvs.py/*checkout*/activewinamp/activewinamp/Release/gen_activewa.dll

Which is the link from:
http://www.myplugins*******activewinamp/doku.php

Or do I just have a problem on my end? Thanks

osmosis
23rd June 2006, 19:11
they changed the architecture slightly i think
http://activewinamp.cvs.sourceforge.net/*checkout*/activewinamp/activewinamp/Release/gen_activewa.dll

should work, and if it ever breaks again
http://sourceforge.net/cvs/?group_id=132165

click Browse CVS Repository and navigate around, you'll find it.

p.s. i just fixed the link on the dokuwiki


also you should update to the newest winamp since the CVS version, while improving some things overall, is generally an update to fix some things that got broken in newer versions of winamp.

MonteCarloPearl
23rd June 2006, 20:22
Thanks Osmosis got it now. Is there any way I can tempt you into helping me with your Party Shuffle script?

osmosis
23rd June 2006, 20:29
i don't really know what i'm doing with it to tell you the truth. i just threw it together out of some examples from the wiki and neFAST's old version. you've probably got as good of a chance of getting it to work as i do using gonemad's suggestion. i'll be glad to help out, but i honestly just don't know where to start with things like this.

MonteCarloPearl
23rd June 2006, 21:15
Fair enough I will see what I can put together over the weekend and see what problems it presents. Should be fun.

foxyshadis
25th June 2006, 04:10
Thanks for updating Toaster, it works like a charm now. Unfortunately updating to the latest cvs compile of gen_activewa.dll hasn't enabled scripting support in WA 5.22 yet; should I try compiling myself? (The "scripts>" is still in the context menu, but none of the scripts show up in it.) Or have some paths changed?

Mmm, I don't know if it's important, but I changed over to a per-user config file when I upgraded last.

Also, since $fill() is not working at all now, should the wiki entry for that be replaced with $repeat()?

shaneh
25th June 2006, 04:55
Haven't tried per user config, but the way ActiveWinamp finds the scripts directory is from where winamp.ini is stored, plus plugins/scripts.. so per user config probably puts this in another place. The .dll works fine with winamp5.22+ for me.

foxyshadis
25th June 2006, 12:38
Ah, finding the new config folder and placing it there fixed it. Thanks!

MonteCarloPearl
27th June 2006, 10:08
I am having a good time with the Party shuffle script but it really does repeat very often. In the 15 videos queued the same video may be there 3 times! I am using the last post of it from NeFast on 5/18 and tried MarquisEXB modification (dated 5/24 but could not get it to work. Can someone give me a corrrect query statement for the following?

mlq = medialibrary.runqueryarray("type = 1 AND (lastplay over [12 hours ago])")

I figure this way it will not replay anything the same night. I am not sure if this will fix the repeat problem but I am hoping. I only have about 700 videos it picks from perhaps my pool is too small? Thanks

neFAST
27th June 2006, 19:08
this "repeat" problem is really strange.
I never faced it !
Maybe you took the version with my Tracknumber=1 trick ?

MonteCarloPearl
27th June 2006, 20:27
I am running v5.21 of winamp. I have ActiveWinamp - v1.0+Beta Gen_activewa.dll file version 1.0.0.1 I am running the attached party shuffle script without the .txt extension. I also get Line 59 Subscript out of range: 'Rand' sometimes. If I re-run the script a couple times it goes away. Sometimes I have to close and re-open winamp to get it to run.

osmosis
28th June 2006, 19:52
neFAST: unfortunately that trick probably won't help him since he intends to use it with videos.

as for that Rand error, i get it too. i have no idea what causes it. just clicking OK and then stopping the script (pressing winamp's Stop button) and running the script again has always worked for me though (ie. i never had to restart winamp).

today i altered the randomization by adding a seed value based on the date and time. i hope this will fix the repeat problems. i'll post back when i'm done testing it.

also, try

mlq = medialibrary.runqueryarray("type = 1 & lastplay < [12 hours ago]")

might fix your query (if not, put the < the other way, the logic behind it being < escapes me right now, but that's what Marquis had, so i'm assuming it's right)

neFAST
28th June 2006, 20:31
Osmosi : I know ! That's the reason why I wanted to check he's not using it.
And quite suprinsingly I don't get any Rand error with the latest version of winamp.

Tell us if your seed value improves something !

osmosis
28th June 2006, 21:58
the occurance of the Rand error is a lot less frequent with 5.24 but i have had it happen to me at least once or twice since updating.

thus far in my testing of the new Randomization i'm happy to report no repeats whatsoever - whereas before i believe i had some by this point (50 tracks) - so, while i plan to subject it to further testing (100 tracks played through - then track skip to see how well it works when fast-paced), i think i'll post it up here and you can help me scrutinize it further.

neFAST: i still haven't gotten around to rating some of my tracks and seeing if they get rotated in more often, did you say your weighted shuffling was working?

v3.0 beta:

[edit - DrO]
removed attachment on request - see here (http://forums.winamp.com/showthread.php?postid=1987584#post1987584) for the prefered version

osmosis
29th June 2006, 03:39
edit: okay wow, i just found that somehow having the Timer at the end of the seed string (making it almost the same value every time) really made it very predictable on load... so i fixed that and my new attempt at fixing randomization is in the next post. new testing with the new seed string is to follow.

osmosis
29th June 2006, 04:10
[edit - DrO]
removed attachment on request - see here (http://forums.winamp.com/showthread.php?postid=1987584#post1987584) for the prefered version

ajaxn99
29th June 2006, 11:08
Originally posted by saivert
Thank! This helped a lot.
I didin't find SP-2 on Windows Update. They claimed it would be installed automatically if I had Automatic Updates turned on for Windows Update. I'll search for it on their search page. Maybe you have the URL??

You are using IActiveScript and IActiveScriptSite right?? Or are you just using "Microsoft Script Control" ActiveX Control?


I just thought I'd let the group know one solution is simply to get the latest version of Internet Explorer. V6 works fine,
particularly if your system is windows 2000 and you can not
get the latest sp for failed validation codes.

DotNet
29th June 2006, 18:32
Is it possible to change the Title / track / author displayed in Winamp?

Reason being, I am using the broadcast plugin, and instead of just sendign out the song I am playing, I would like full control of the text displayed.

many thanks in advance

osmosis
29th June 2006, 20:53
250 total plays:23 total repeats (in a ~10,000 track library) are the results for that latest one, and skipping fast through tracks seems to work nicely.

neFAST
30th June 2006, 00:02
How do you count ? Manually or within the script ?

osmosis
30th June 2006, 01:17
i reset my playcounts, let it run all night and day, and then looked at Most Played

MonteCarloPearl
30th June 2006, 04:10
You guys are really awesome. Thank you for the work you are doing. By using Osmosis numbers on repeats, songs played, library size and applying it to my library size which is actually only 300 at this point as I dont have all the videos on this system yet. I can expect about 2 repeats every 15 songs quequed and thats pretty darn close to what I am getting, sometimes a little more. Its like it gets stuck on a particular video and keeps queing it. Was there a particular track that seemed to get played alot more than the others in your Most Played? I am using the latest version of the script uploaded 6/28. I have not tried applying the last 12 hours thing yet. And I have not upgraded to 5.24 yet. Would you recommend I do that at this time? Thanks again.

osmosis
30th June 2006, 04:36
i do recommend you upgrade to 5.24, that will allow you to both slim down winamp more to suit your (limited) needs and should resolve the majority of the occurances of those "Rand" bugs. The latest version of the script is actually 6/29 by my watch, if you have 6/28, get 6/29 (the "sigh" one). and yeah, there was 1 track with 3 repeats and then 10 more with 2. for your purposes you should apply the 12 hours mlq i posted above, it should fix all your problems with repeats, also you don't need to use my crazy seed value (you can just change it back to simply Randomize) since the 12 hours thing will narrow it down and the regular Randomize is good enough for what you need it for.

as for music party shuffle, i still don't find that number of repeats acceptable and i didn't want to have to resort to keeping track of last played or anything like that, so i'm not sure what to do. also, neFAST, please answer my question concerning your weighting attempt.

MonteCarloPearl
30th June 2006, 04:59
I will apply your suggestions over weekend and report back with results. Again thanks so much for the help.

neFAST
30th June 2006, 22:08
@Osmosis : my trick is not compatible with the weightening so I just tested it a few days. Didn't get any noticable difference ... but I have only a few rated song in my library.

I've done some math and for 250 and 10000tracks I get a mean repeat of 3 (but I'm not confident in my formula).
How many repeat do you get without your date-based seed ?

osmosis
2nd July 2006, 23:05
it can still get to around 80 or 100 without repeating at all, but then it turns out to be about the same. is it possible that the method that we're using to get a random media library entry could be the problem?

MonteCarloPearl
9th July 2006, 02:50
Wow what a week it has been for me. I think I put in 70 hours or so working on various projects. Hope you all are doing well. I did some playing around and really hacked up your party shuffle script and added the simple random script into it and actually got some pretty nice results for my purposes. In looking at the script it seems that the Media library is queried only once to build a list and then songs/videos are randomly chosen from that list however at no point is there a check to see if a song has played in the last so many hours. I tried to put something together but it doesnt work. My idea is that when adding a song to the list a quick check is done to see if it has played since 5 am ( thats when I was working on it) if it has then chose another one and test it again. Keep doing this until a song is chosen that has not played since 5 am. I am sure my script doesnt work because I am just typing it wrong. Please advise and thanks.

' +--------------------------------------------+
' | Party Shuffle Simple Rand with test 1.0 (15 track version) |
' +--------------------------------------------+
' Automatically enqueues a new random song each time another is played.
' An ActiveWinamp script originated by osmosis and neFAST, modified by
MonteCarloPearl

' Changes: 1) Randomization adapted from simple randon script.
' 2) Playlist now definitely contains only VIDEO items.
' 3) Added a test to see if randomly selected video has played
since a certain time

' Todo: 1) Troubleshoot the test to see if videos have played and if so
choose a different one
' to enqueue.
' 2) A test to see if videos are in playlist and if so choose a
different one
' to enqueue.

' July 4, 2006

Dim mlq,num,Rand,rand2,startup,pos,pchg

' This is the first launch
startup=MsgBox("Start new Party Shuffle playlist?",_
vbYesNoCancel+vbDefaultButton2+vbQuestion,"Winamp Party
Shuffle")

if startup=2 then
' abort if requested
quit
end if

' clear PL if desired
if startup=6 then
playlist.clear
end if

Randomize
mlq = medialibrary.runqueryarray("type = 1")
num = 10 ' CInt(InputBox("Number of items"))
tracks = 0

do while (tracks<num)
Rand = Int(ubound(mlq) * Rnd+1)
if [mlq(Rand).lastplay>05:00:00] Then
Do while [mlq(Rand).lastplay>05:00:00]
rand2 = (Rand + Int(ubound(mlq) * Rnd+1))
set Rand = rand2
Loop
end if
mlq(Rand).enqueue
tracks=tracks+1
Loop

if startup=6 then
' Now let's play
play
end if

Sub Application_ChangedTrack

if playlist.position>6 then
' We delete however many the PL position has changed by
pos=playlist.position-6
pchg=0
Do while (pos>pchg)
playlist.deleteindex(1)
pchg=pchg+1
Loop

end if

if playlist.count<=(playlist.position+8) then
' We add songs until there's a backlog of 5 (startup)
' or until we've reached 15 again
Do while (playlist.count<=(playlist.position+8))
Rand = Int(ubound(mlq) * Rnd+1) ' Here we are grabbing a random
number corresponding to
' a video from MLQ
' we need a test to see if that video has played in last 12 hours
' if so grab another and retest it
' once passed go ahead and enqueue it
if [mlq(Rand).lastplay>05:00:00] Then
Do while [mlq(Rand).lastplay>05:00:00]
rand2 = (Rand + Int(ubound(mlq) * Rnd+1))
set Rand = rand2
Loop
end if
mlq(Rand).enqueue
Loop

end if

End Sub

Sub Application_ChangedStatus

if PlayState=0 then
' exit if state has changed to stopped
quit
end if

End Sub

MonteCarloPearl
10th July 2006, 09:36
I am having no luck at all with the lastplay thing fixing my repeat issues so I am now trying something different. I am working on a playcount test. My thought is, I can reset all my playcounts to 0 then as items are chosen to be enqueued a quick check is done to see if they have a playcount => 1 if so then reset the value for rand and try again, loop until an item with a playcount of 0 is found.

This is what I have put together. Any comments on what I am doing wrong would be great.

Also, is there a way to review the playlist and remove duplicate items? Sometimes a video is enqueued twice (or more) before it has had a chance to play. Consequently it would satisfy the above test (if it actually worked) as it has not played but yet would result in a repeat.

MonteCarloPearl
12th July 2006, 04:21
Worked all day on this and I have finally solved the repeat issue. I used a 2 way test solution involving a playcount test and figured out how to check the existing playlist before a video is even enqueued! I will put files up tomorrow as I need to clean them. Thank you to all for your help. More tomorrow!

Nightbreed
12th July 2006, 05:22
Hi.. I've been able to get all the media info to display correctly, namely the artist, Title, etc... however the Lastplayed doesn't seem to return anything. Is this broken or am I probably calling it wrong?

MonteCarloPearl
12th July 2006, 05:53
OK Here is the fruit of my labor. I want to thank ShaneH for an awesome plugin without which I could not have completed this project. Furthermore thanks to NeFast and Osmosis for putting together a great script and helping to adapt it to my particular situation even though my environment is nowhere near what theirs is. Also thanks to all that have contributed to this whole thread as I learned from a lot of people. I had just about no scripting experience prior to this and because of this thread and a couple other resources I think I did pretty good. I will include the script I am using in production as well as a more general use adaptation. For a complete idea of what my production script does refer to my first post on page 10 posted 6/22/06 at 4:04. Enjoy and thanks again.

MonteCarloPearl
12th July 2006, 05:54
Heres my production script again refer to my previous post to get an idea of what it does.

As far as the repeat issue I played 95% of my entire media list 700+ videos without a single repeat before the safety kicked in and ended the script.

MonteCarloPearl
12th July 2006, 06:01
And lastly, for all the other beginners out there I found this resource almost invaluable.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/9233ea93-1f8d-4ac5-9ad9-d27ecff00da4.asp

I will also include a very early version of my script. As you can see I made rampant use of "msgbox" to stop the script and get an idea of what it was doing. You real coders will just laugh but for someone like me (that pretty much doesnt have a clue) this really helped my troubleshooting. Thanks again to all.

osmosis
13th July 2006, 14:39
sorry i've been too busy to help you with your later questions. i'm glad you worked it out. i'll check out your scripts and that msdn vbscript page. personally i've been using w3schools: http://www.w3schools.com/vbscript/vbscript_ref_functions.asp and highly recommend it as well.

osmosis
17th July 2006, 02:49
ended up using Marquis' enqueue cache to fix the repeat problem. Breaks the current weighting attempt though, so another will have to be devised. Since this resolves my major issues with the script i've posted the 15 track version to the Examples wiki (http://www.myplugins*******activewinamp/doku.php/examples:root), and the 20 track version is here for those who would prefer a longer playlist and don't feel like changing it themselves:

MonteCarloPearl
19th July 2006, 23:23
How can I enqueue a script? There is an example to insert a script but I can't get it to work. I need to enqueue a script named "onetoall.vbs" and "onetoone.vbs". These scripts are stored in the scripts folder along with the others. In my case I need these to get put in just before and just after the Movie clip is inserted in the modified party shuffle script I uploaded a few days ago. Also, on another front, there is mention in the help file of a volume property. Can this be used to control the volume level? i.e. turn up for certain clips and down for others? If so how would I do it? Thanks

osmosis
20th July 2006, 02:13
example from the wiki on inserting:

Set mi = LoadItem("C:\song.mp3")
mi.Enqueue

'Or insert it at a given position

mi.insert 5

'Alternatively, you can obtain the MediaItem from the
'Media Library or the Playlist. ie.

Set mi2 = Playlist(4)
mi2.Enqueue

and in order to put a script as a playlist entry you use script:\.. so you should be able to set mi or whatever to LoadItem("script:\onetoall.vbs") etc and have it do that.

MonteCarloPearl
24th July 2006, 21:48
Thanks Osmosis that gets my scripts enqueued perfectly. I now have a question on how external apps get played or called from the playlist. I assume when winamp gets to them it should launch them and then go on to play the next item in the playlist. Is this correct? Is there anything that needs to get added in order for an external app to get launched?

My problem is that while my progams show up in the playlist they are not being executed. I know the programs work cause if I double click them (outside of winamp)they do exactly what they are supposed to do. In Winamp they show up on the playlist, winamp gets to them, then goes to the next item and never errors out.

Additional Info -

My AlltoOne and OnetoOne programs are simple 4byte commands sent out Com2 to a video router that causes it to change configurations. No reply is necessary. The zip file here contains my latest version of the party script, the eternal programs it calls and the source for the external programs. AlltoOne and OnetoOne require .Net 2.0 installed which I have done and they were created using VB Express edition.

osmosis
24th July 2006, 21:54
sorry, i guess there was a bit of a misunderstanding. i thought you were trying to enqueue other scripts.

script:\ is only used to call .vbs's (not .exe's) as that's all that activewinamp has support for from the playlist. make 2 .vbs's that run their respective .exe and you should be fine. I'd guide you through that but I don't know how to do that offhand. however, if you look at the wiki or any of your vbscript resources, i'm sure they can show you how to call external exe's from within a script.

MonteCarloPearl
24th July 2006, 22:02
That makes sense! I will review the examples and if I have more trouble I shall post. Thanks!

MonteCarloPearl
24th July 2006, 22:18
Got it thanks again for that one little piece I was missing! I created the AlltoOne.VBS and heres what It looks like:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "D:\AlltoOne.exe"
quit

It gets called from playlist, lanches my app and just works awesome!
Things are looking great and now I am in final testing!

osmosis
25th July 2006, 07:39
Good to hear MonteCarlo, glad to help. :)

And man.. i was just looking back through this thread and it looks like there are A LOT of scripts that aren't on the wiki.. if any of them still work then someone should put them up for everyone.

IllBugYou
7th August 2006, 16:05
Can someone help me with enqueuing a file using this as a COM object in C#.



private static ActiveWinamp.Application winamp = new ActiveWinamp.Application();
String m;
m = "c:\mysong.mp3";
winamp.LoadItem(ref m);


Everything's works up to that point, but I can't find the method enqueue and make it work.

I had this:

ActiveWinamp.MediaItem myNewFile = new ActiveWinamp.MediaItem();
myNewFile.Enqueue();

but that just causes the application to crash.

Any help would be greatly appreciated. Thanks.

shaneh
8th August 2006, 01:25
LoadItem returns a MediaItem. Thus you would do something like:

ActiveWinamp.MediaItem myNewFile = winamp.LoadItem("song.mp3");
myNewFile.Enqueue;

I will look into why trying to enqueue an empty media item crashes. Probably just trying to convert a NULL string to ansi or something.

IllBugYou
8th August 2006, 14:35
Originally posted by shaneh
LoadItem returns a MediaItem. Thus you would do something like:

ActiveWinamp.MediaItem myNewFile = winamp.LoadItem("song.mp3");
myNewFile.Enqueue;

I will look into why trying to enqueue an empty media item crashes. Probably just trying to convert a NULL string to ansi or something.

Small Correction for C# newbs like me: myNewFile.Enqueue();

Works like a charm!

Thanks Shane! This tool is incredible!

tka.lee
14th August 2006, 08:30
I just updated to Winamp v5.24 (x86) (June 21) and it's done something weird to the increase/decrease playcount scripts. When I decrease playcount it goes straight to 4294967295. Then I increase it and it goes to 1, but no higher.

Help! I'm a newbie and know nothing about coding. I read about a page ago on this thread that shaneh was going to release a new activewinamp version. Any news on that?

Failing that, is there a workaround that will restore the script functions?

A related shaneh plugin worry (this time with playcount tracking replacement): Some files will crash the player when the playcount tracker kicks in. When I disable the tracker there's no problem, but then tracks don't count up. Has anyone noticed this, or has a fix?

Thanks!

tka.lee
14th August 2006, 08:31
Forgot to say, shane, I love your plugins, and had no problems until I upgraded the main program. (so sad..)

shaneh
14th August 2006, 08:34
Are you using the latest gen_activewa.dll from the CVS? Make sure you are.
http://www.myplugins*******activewinamp/doku.php/

The playlist tracking plugin is a bit broken if the song has no playcounts attached to it. You could write a sendto script to assign a playcount of 0 to everything with no playcount. I probably should update it, Im not sure if it even works anymore.

Lucky Luke
14th August 2006, 14:12
Hi Shane,

I have a little problem trying to create a winamp object Jscript.

I'm creating a MSN Plus Live script.

Here's the code:

var winamp;
var playlist;
var shell;

function OnEvent_Initialize(MessengerStart)
{
try
{
winamp = new ActiveXObject('ActiveWinamp.Application');
}
catch (e)
{
Debug.Trace("Could not create winamp Object");
MsgPlus.DisplayToast("MSN Winamp", "Could not create winamp object. Have you installed ActiveWinamp?\n\nClick here to install Active Winamp", "", "OnWinampErrorToastClick");
}

shell = new ActiveXObject('WScript.Shell');

var x;
for(x in winamp)
{
Debug.Trace(x);
}

// So far, so good. Ik get no errors
// But in my script debugger, I also get 0 properties
// (See for loop above)
}

function OnEvent_Uninitialize(MessengerExit)
{
}

function OnWinampErrorToastClick(param)
{
shell.Run("http://www.myplugins*******activewinamp");
}

function OnGetScriptMenu()
{
return "<ScriptMenu><MenuEntry Id='MenuCurrentSong'>Send Current Song</MenuEntry></ScriptMenu>";
}

function OnEvent_MenuClicked(id, Location, wnd)
{
if(id == "MenuCurrentSong")
{
wnd.SendMessage(winamp.playlist[winamp.playlist.position].ATFSTring("[%artist% - ]$if2(%title%,$filepart(%filename%))"));
// At the line above, I get an error. winamp.playlist[...] is null or something
}
}



See the comments. I get no errors when creating the object. But is has no properties at all...

Does anybody know what the problem can be?

tka.lee
15th August 2006, 00:37
Originally posted by shaneh
Are you using the latest gen_activewa.dll from the CVS? Make sure you are.
http://www.myplugins*******activewinamp/doku.php/

The playlist tracking plugin is a bit broken if the song has no playcounts attached to it. You could write a sendto script to assign a playcount of 0 to everything with no playcount. I probably should update it, Im not sure if it even works anymore.

Thanks for the advice, Shane. I'll try that out tonight after work.

tka.lee
15th August 2006, 08:03
Shane, I tried out the latest gen_activewa.dll and it's worked a beaut so far.

Cheers, yr a star!

Tony

Anreal
25th August 2006, 21:14
Originally posted by osmosis
ended up using Marquis' enqueue cache to fix the repeat problem. Breaks the current weighting attempt though, so another will have to be devised. Since this resolves my major issues with the script i've posted the 15 track version to the Examples wiki (http://www.myplugins*******activewinamp/doku.php/examples:root), and the 20 track version is here for those who would prefer a longer playlist and don't feel like changing it themselves:

Hi, I have modified your script that it work with Smart View. Also I have added checking of presence of a finded song in the view of a recently played songs (with rating staf). but it's work very slowly and perhaps not so properly as I would like.

osmosis
25th August 2006, 22:03
oh awsome, smartview, very clever! even more iTunes-y (not in a bad way in this case) :D

checking it out now... having trouble getting it to actually work.. i guess i have to have a track selected to actually make the Send To work.. but then i get Line 51 Subscript out of range: 'RandArtist' .. i'll take a look at the code see what i can work out.

Anreal
26th August 2006, 14:36
Yes, I see, for the moment it's work only if you select big numbre of songs (100 or more), I dont know why it's work like this.

osmosis
26th August 2006, 18:46
i tried it by selecting my entire library since i thought that might be the case that it needed it all, didn't work, i get a Error Line 57 - Type Mismatch: 'mlqHistory' hmm, just got it again now with only 100 selected as well.

perhaps you could explain how you set up and use this script with the ML and PL and everything in a bit more detail?

Anreal
27th August 2006, 10:52
Sorry, it is an old error, I have forgotten to update a text file before to upload it. You should change mlqHistory on mlqForHistory in that place or download this file one more time.

P.S.: I use this script for entire Smart View (~1000 songs). I choose that Smart View with right click, I choose my script, and that's all.

Anreal
27th August 2006, 11:00
Ups, i dont have permission to update Attachment in my early post.

osmosis
27th August 2006, 16:06
ah there it goes. cool idea, you're right about it queueing the files up quite slowly though, at least on first load. if i had to guess i'd say it must be the rating loop that causes it, especially since none of my tracks are rated. do you think that could be the case?

osmosis
27th August 2006, 22:00
very slight optimization of my last post of the party shuffle (20 track version) available as a forum attachment here: playlist_Party Shuffle (20).vbs.txt (http://forums.winamp.com/attachment.php?s=&postid=2018077).

don't know why i didn't think to just make a subfunction for the trackloading before. :P

azizabdulmalik
28th August 2006, 06:47
yeah, playlist_Party Shuffle (20).vbs.txt is a good script!

Anreal
28th August 2006, 20:57
Originally posted by osmosis
ah there it goes. cool idea, you're right about it queueing the files up quite slowly though, at least on first load. if i had to guess i'd say it must be the rating loop that causes it, especially since none of my tracks are rated. do you think that could be the case?

Yes, it's a rating fault, I have worked on it litle bit and voila - new version, without a Randomization bug (in case of a small selection) and others.

P.S.: And I have find a new one :) - if you launch the script twice then track finded on event ChangedTrack is not from second selection of tracks but first. Only complete winamp restart may help.

osmosis
29th August 2006, 17:16
you could just go into the ActiveWinamp plugin display and kill the one/both of the ones you don't want instead of restarting.

gonemad
30th August 2006, 16:26
edit: nm looks like you changed it

Ike987
21st September 2006, 21:38
Nice script osmosis, very useful. Can I assign this script to a hotkey somehow so I can run it from anywhere?

billyvnilly
21st September 2006, 21:45
shane made all scripts automatically have global hotkey function. goto global hotkeys and it should be there.

Ike987
21st September 2006, 21:53
That was quick, thanks. Didn't expect it to be that easy!

lual
28th September 2006, 16:21
hi folks,
as i've seen on
http://www.myplugins*******activewinamp.htm
there should be this script...
"Automatic shutdown of Winamp or Computer at end of playlist"
but where is it? i can't find it.
i'd like to shutdown windows. preferable with a 10 seconds selfclosing messagebox to interrupt the script. (but that feature is not so importand.)
please help me.
regards lual

lual
28th September 2006, 21:18
here is my own solution...

'Script by lual 2006-09-28
'Call this script in winamp-playlist to shutdown winXP
'script:\Shutdown Windows.vbs

idy = SetTimeout(60000, GetRef("downsys"))

Answer=MsgBox("Last chance to cancel the countdown."+vbCR+vbLF+_
"OK to shutdow immediately.",_
vbOKCancel+vbDefaultButton1+vbCritical+vbMessageBoxSetForeground,_
"System will shutdown in 60 seconds!")

If Answer=vbCancel then
CancelTimer(idy)
MsgBox "Shutdown request cancelled.",vbInformation,"On the road again."
Quit
Else
CancelTimer(idy)
downsys
End if

Quit

Sub downsys()
Dim WSHShell
Set WSHShell = CreateObject("WScript.Shell")

'methods of shut down windows described e.g. here...
'http://www.aumha.org/win5/a/shutcut.php

'this didn't worked well for me...
'WSHShell.Run "TSSHUTDN.EXE /POWERDOWN", 1, false

'this is better, but needs the tool from...
'http://www.aumha.org/downloads/shutdown.zip
'(copy shutdown.exe in your script dir)
'(don't mix it this with the windows command "shutdown")
' -h: Hibernate.
'WSHShell.Run "C:\Programme\Winamp\Plugins\Scripts\shutdown.exe -h -f", 1, false
' -u: Shutdown (Turn Off).
WSHShell.Run "C:\Programme\Winamp\Plugins\Scripts\shutdown.exe -u -f", 1, false

Quit
End Sub

____
lual

osmosis
29th September 2006, 21:29
any progress with the sendto script Anreal? i had a thought. if you weren't doing the sendto from the ML (ie. the PL editor's Send To menu) could you make it default to the whole library? that way you could still trigger it from the PL editor nicely.

@laul: there's also a rundll method of shortcutting to the shutting down of windows and your computer. would probably be better since it wouldn't require 3rd party exes, but if that doesn't work then you'd want to change your directories in the call to have the %PROGRAMFILES% environment variable. that way it would work on any system.

see http://vlaurie.com/computers2/Articles/environment.htm
and http://www.burzurq.com/forum/shutdown_icon.html (i'd go with %WINDIR% if scripting the rundll method)

shaneh
5th October 2006, 22:22
You have to add the item to the playlist in order to play it. You can remove it afterwards if you like and it will continue to play.

Just enqueue it, then set the playlist to the last item then play.

ie.

mi.enqueue
oldpos = playlist.position
playlist.position = playlist.count
winamp.play
playlist.deleteindex(playlst.position)
playlist.position = oldpos

or something like that. I really should make enqueue set the mi.position, this currently isnt done. This would allow you to do:

mi.enqueue
mi2.enqueue
playlist.position = mi.position
winamp.play

note that this isn't currently possible.

styx432143
25th October 2006, 16:01
I am writing a smallscript to make winamp automaticly add files from a folder to the playlist.
I use the medialibrary to monitor a folder for new files.

Then this script will import from medialibrary.


dim a,b

Sub Application_ChangedTrack

StopPlayback
'playlist.item(0).playcount = playlist.item(0).playcount - 1
a=0
b=0
do
mlq = medialibrary.runqueryarray("type = 0 AND Playcount = " & b)
playlist.clear
for each track in mlq
track.enqueue
a=a+1
next
if a=0 then
b=b+1
end if
loop while a=0
Play

End Sub


It works fine until there is only one song in the current PL, then winamp crash.

Could someone please take a look and help me out?


I also wonder if there are any way of making this work for videos added to medialibrary as well?


Thanks

styx432143
25th October 2006, 19:36
Fixed the problem myself :)

styx432143
26th October 2006, 09:37
No, I still experience some crashes. My code is still basically the same as above.
what could be causing the crashes?
What happens when medialibrary.runqueryarray() cant get any hits matching the query?

Thanks

Hayden_54
6th November 2006, 20:59
I'm using this Random Playlist code (can't remember who made it originally):

Randomize
mlq = medialibrary.runqueryarray("type == 0 AND playcount <= 10 AND lastplay < [3 weeks ago]")
num = CInt(InputBox("Number of items"))
tracks = 0
do while (tracks<num)
Rand = Int(ubound(mlq) * Rnd+1)
mlq(Rand).enqueue
tracks=tracks+1
Loop
quit

Just wondering how I can change it to overwrite the playlist and play rather than just enqueue it. I don't really know much about how any of this works...I tried the simple thing of switching the word enqueue to play but that didn't work!

Could somebody help me out with this please.

shaneh
6th November 2006, 21:14
Just add a

playlist.clear

at the start of the code.

Hayden_54
6th November 2006, 21:22
Thanks! Is there also a way to get it to start playing the first song in the new playlist?

shaneh
6th November 2006, 21:23
playlist.position=1
play

Hayden_54
6th November 2006, 21:30
Awesome...works perfectly. Thanks for all your help.

osmosis
30th November 2006, 02:57
if you go to Add View in the Media Library and then to Advanced Editor, all the documentation for the query language are in there.

bwechner
2nd December 2006, 11:09
I'm trying to write a small C# app and need to use the ChangedTrack callback. I base it upon the C# sample project supplied with ActiveWinAmp. Alas the callback doesn't work in that demo, nor in my app, and I'm at a loss as to why. Here's what the relevant code looks like:

WinAmp = new ActiveWinamp.Application();
WinAmp.ChangedTrack += new _IApplicationEvents_ChangedTrackEventHandler(DisplayCurrentSong);

The method DisplayCurrentSong is never called when the playing track changes. What is it that isn't being done right? How to diagnose it? How can I get this callback to work properly?

Has anyone got a C# app working like this and care to share experiences?

e1v
7th December 2006, 00:27
I've created a program for displaying album ratings etc, described here:
WinampRatings (http://e1v.blogspot.com/2006/12/winamp-ratings-statistics.html), I hope sombody can test it and tell me what the thing (if it works)

Anyway, it's a c# program and I'm reading from winamp using activewinamp like this:

static Application winamp = new ActiveWinamp.Application();
static ActiveWinamp.MediaLibrary mediaLibrary = winamp.MediaLibrary;
...
...
foreach (ActiveWinamp.MediaItem item in mediaLibrary)
{..read info into my collection ..}

But it's very slow. Is there any quicker way to read the medialibrary with ActiveWinamp?

shaneh
7th December 2006, 00:36
It might be quicker to use

MediaLibrary.RunQueryArray('')

This will load the entire results into an array then return that. This way, it would only require one (albiet big) inter-process marshal. This is pretty much the reason I implemented that function.

e1v
7th December 2006, 07:24
OK, thanks, I'm new to interop programming. Now I tried using

Array trackArray = (Array)winamp.MediaLibrary.RunQueryArray("type=0");

foreach (object obj in trackArray)
{
MediaItem item = obj as MediaItem;
string album= item.Album;
//... read stuff from item into my table
}

but it's only 10% faster. It's still the foreach loop that is taking the longest time, and winamp is using 50% cpu during the foreach, so it must be communicating with winamp for every item read.

bwechner
7th December 2006, 20:48
Winamp forums seems to have booted my account during a recent change? Hmmm, anyhow, can't use old account as allegedly it doesn't exist when I try to logon. But I'm still keen to learn something about this:

I'm trying to write a small C# app and need to use the ChangedTrack callback. I base it upon the C# sample project supplied with ActiveWinAmp. Alas the callback doesn't work in that demo, nor in my app, and I'm at a loss as to why. Here's what the relevant code looks like:
code:WinAmp = new ActiveWinamp.Application();
WinAmp.ChangedTrack += new _IApplicationEvents_ChangedTrackEventHandler(DisplayCurrentSong);The method DisplayCurrentSong is never called when the playing track changes. What is it that isn't being done right? How to diagnose it? How can I get this callback to work properly?

Has anyone got a C# app working like this and care to share experiences?

shaneh
10th December 2006, 09:26
The example included with the activewinamp distribution (AWExamples/waform) is a C# application which handles track change events.

I just tested it and it works ok with Winamp 5.3

bwechner
12th December 2006, 21:26
Alas I tested it too and didn't work. I'm happy to try again when I get home (having tried a few times already). And I'll give it a whir on another PC too. But if I'm stuck, what diagnostic tools are there for seeing why an event driven callback fails?

The example C# app in fact is the only way I could divine that the ChangedTrack property needs for some reason I don't understand the += incrementor rather than the = assignment operator.

shaneh
12th December 2006, 22:50
Are you sure your 'Winamp' object is global? It will be destroyed (along with all event handlers) once it goes out of scope if not.

At line 15 you can see it is global:
http://activewinamp.cvs.sourceforge.net/activewinamp/activewinamp/Package/AWExamples/waform/Form1.cs?revision=1.2&view=markup

The reason it needs a += rather than assignment I suspect is because you want to "add" a handler to the list of handlers, not override the handler.

bwechner
12th December 2006, 23:44
Shaneh, thanks. I'm confident and will check when I get home again (to see my code). I can't rule out an obvious error (very common after all) but I am aware of scoping issues. I'll report back here.

But, I can't get the provided demo to work either. Well it compiles and runs just fine on my box at home and functions quite well, except for the callback it seems (a break point there never triggers wen I change WinAmp tracks).

I have the same interpretation of the += requirement, but to be honest I am in lieu of understanding the consequences happy to override the event handler. I'm left assuming that perhaps there in a WinAmp internal handler that if overrridden has some unpleasant side effects (WinAmp not functioning correctly). Who knows? It seems to be by design of ActiveWinAmp or WinAmp anyhow that this eventhandler cannot be overridden.

Pamarro
17th December 2006, 08:07
How do u write scripts for the following actions?

- Add currently playing song to Bookmark
- Open 'View file info...' box

There don't seem to be Global Hotkeys for these two actions, so thats why I'm asking.