Old 2nd December 2004, 12:56   #161
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Nope I guess not. If its the current track, you can use tricks with the window title of HWND to get the winamp title. Otherwise you have to do it without the help of AW and use ReadProcessMemory if the program is not running in the same process space as winamp.

I will add a IPlaylist.GetTitleOfIndex() type method. Id rather not just add methods here and there, but add a whole bunch of upgrades and make a new interface, ie. ActiveWinamp.Application.2 etc. That is the proper way to do it in COM, otherwise you never know what methods are supported by the interface.
shaneh is offline   Reply With Quote
Old 6th December 2004, 00:23   #162
herd
Junior Member
 
herd's Avatar
 
Join Date: Nov 2004
Location: Germany
Posts: 7
Adding methods is no problem - removing or altering them is.
Should be no problem if you are still in beta.

Would you mind sharing the source? I could help and e.g. integrate ID3 support into the IMediaItem... I am seasoned with COM but kinda new to WinAmp coding.
herd is offline   Reply With Quote
Old 6th December 2004, 01:23   #163
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Quote:
Adding methods is no problem - removing or altering them is.
Should be no problem if you are still in beta.
Are you sure? I would think youd need to create a new interface so that applications that get your interface have an expected set of APIs to use. ie, if you get the interface x, you can assume that function foo exists. If 'foo' was introduced later, the application would crash trying to call it. It has no way of determining what functions exist other than some kind of version call. To do away with version tracking, you simply try get the interface number as high as you need, and can assume a certain level of functionality on that interface.

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

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

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

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

You can use id3com to access ID3 tags. Take a look at the sendto_id3 export. example. Finding a copy of ID3com takes a bit digging though. I think its released as part of id3lib in source form. I dont think Id want id3 support in AW, its meant to be an interface to Winamp, and nothing more. Itd be like adding filesystem support to a calculator interface or something. To me, it makes more sense to use external 3rd party libraries to do external 3rd party stuff.
shaneh is offline   Reply With Quote
Old 7th December 2004, 09:13   #164
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
COM interfaces can be very useful when you have know how to work with them. I don't think people should start learning programming using COM as their first step. Maybe if Winamp itself loaded plugins as COM objects like the Explorer loads Shell Extensions, we would have a much easier life (in programming).
saivert is offline   Reply With Quote
Old 11th December 2004, 02:05   #165
bradroger
Junior Member
 
Join Date: Dec 2004
Posts: 1
I want to create a script that will reduce a song's playcount by 1 if it is skipped in the first 10 seconds or so. Then if your playlist is shuffling along and you skip a song, it doesn't show up as if you've played it. It should be pretty simple but I'm just learning how to do all this so I need a little help. I'm not sure how I can have a script constantly running in the background, without having to loop continuously and bog down the system. Is this possible?
bradroger is offline   Reply With Quote
Old 11th December 2004, 04:05   #166
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I actually had a script that did just that, but Ive since deleted it.

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

It would look similar to:

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

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

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

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

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

A better script would probably store the filename of the currently playing song then check that after 10 secs rather than the current playlist pos. Or cache the "mi" and check the filename of that vs the currently playing filename on the timer event. Left as an exercise...

Last edited by shaneh; 11th December 2004 at 04:20.
shaneh is offline   Reply With Quote
Old 16th December 2004, 01:40   #167
Thunder Pussy
Feed me a stray dog
(Major Dude)
 
Join Date: Oct 2004
Posts: 1,122
Hi, just thought I'd post a script I've been using in case somebody else could use it. This is just a simple modification of the playllist_Rand items script that comes bundled with A/W. It enqueues 100 random songs that haven't been played in the last 7 days.


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

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

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

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

Randomize
itms = Dict1.Items

num = 100

do while (tracks<=num)

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

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

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

tracks=tracks+1
Loop

quit




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

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

Have a good one and thanks,


/edit p.s. Shaneh, would you consider adding year as a supported value for future versions of A/W? It would be cool to be able to enqueue or insert random all from year.
Thunder Pussy is offline   Reply With Quote
Old 16th December 2004, 02:10   #168
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Ah.. left "Year" out, plus a couple other things. Will put 'em in a future version. Fortuantly most things can be covered with "sendmsg" and 'ATFString' hacks.

To get the year, using mi.atfstring("%year%") should work.
shaneh is offline   Reply With Quote
Old 16th December 2004, 02:54   #169
Thunder Pussy
Feed me a stray dog
(Major Dude)
 
Join Date: Oct 2004
Posts: 1,122
That is where it goes over my head. I am fine with waiting for a future version, should you wish to accomodate it. Year is not very high in my priorities, although it would be neat.
Thunder Pussy is offline   Reply With Quote
Old 25th December 2004, 15:42   #170
neFAST
Member
 
Join Date: Sep 2004
Location: Montreal
Posts: 56
Send a message via ICQ to neFAST
Re: Three from One script

Quote:
Originally posted by CaAl
I've written a script that automatically enqueues a song each time a new song is played, in such a way that you'll get three songs in a row from a random artist, followed by three in a row from another random artist. Toggling the script on/off can be done via the configurationwindow of Shaneh's plugin.
Would be nice if we could switch a script on or off with a right clic instead of the config window ...
I'm planning to write a "party shuffle" similar to Itunes' one using this "active script" feature. But it would be very useful to lauch or stop it quickly from the "Script" menu !
neFAST is offline   Reply With Quote
Old 26th December 2004, 15:12   #171
neFAST
Member
 
Join Date: Sep 2004
Location: Montreal
Posts: 56
Send a message via ICQ to neFAST
Finally I decided to trigger "Three from one" with a specific track header. So when I launch my playlist with that fake track, 3from1 is active. And when i listen to a track or an album it's off.

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

Anything planned to fix it ?


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

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

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

Sub Application_ChangedTrack

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

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

neFAST is offline   Reply With Quote
Old 30th December 2004, 01:39   #172
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
AW doesnt remember 'running scripts' in the same way Windows doesnt remember running programs. If you want something to start at startup, name it 'startup_x.vbs'.

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

AW currently just uses the running script dialog for running scripts. I may include another sub menu for running scripts which lets you stop them more easily. Theres a bit I need to do with regards to script management (hot key callbacks, menu item registering/callbacks, etc etc..).
shaneh is offline   Reply With Quote
Old 3rd January 2005, 22:18   #173
neFAST
Member
 
Join Date: Sep 2004
Location: Montreal
Posts: 56
Send a message via ICQ to neFAST
your right, startup mode is exactly what i was looking for ! I thought startup would only launch the script once.

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

Any idea to optimize that ?
neFAST is offline   Reply With Quote
Old 5th January 2005, 10:51   #174
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Im guessing theres an issue with the meta data retrieval on creation of a "MediaItem". I will look into it soon.
shaneh is offline   Reply With Quote
Old 11th January 2005, 16:32   #175
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
Help file?

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

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

[edit]
Found it, if it's gen_activewa.chm.
Apparently I can't delete my post so it'll have to stay...
Never mind he!

Last edited by Wabiloo; 11th January 2005 at 18:09.
Wabiloo is offline   Reply With Quote
Old 11th January 2005, 21:46   #176
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
Quote:
Originally posted by shaneh
You need to put id3com.dll wherever you like, then run

regsvr32 id3com.dll


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

Any idea what could be the problem? (sorry I'm not used to programming under Windoze)
Wabiloo is offline   Reply With Quote
Old 11th January 2005, 23:28   #177
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
id3com not id3lib.
shaneh is offline   Reply With Quote
Old 11th January 2005, 23:45   #178
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
Quote:
Originally posted by shaneh
id3com not id3lib.
Ah, OK, not the same thing. I read the id3com is a wrapper, whatever that means.
Couldn't find a compiled version in their distribution though, so I had to find it somewhere else.
Do you have any idea where I could find the object reference for it?
Wabiloo is offline   Reply With Quote
Old 12th January 2005, 13:36   #179
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
ID3Lib is a completely different project. You don't even need ID3Lib cos' ID3Com has built in functions for reading tags.
saivert is offline   Reply With Quote
Old 13th January 2005, 08:37   #180
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
A playlist event

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

This is for me to write an external application that would interact with current software I'm using so that I have total control over the playlist, but can still let other applications change the playlist and be aware of the changes.
Wabiloo is offline   Reply With Quote
Old 14th January 2005, 10:06   #181
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
@saivert: id3com uses id3lib. Much of the source is shared between projects either as source or binary. If you download the id3lib project, you will get the id3com source as well. There are some prebuilt id3coms around.

@wabiloo: Thats possible, however it would fire far too often. That message is fired far more often than is practical to do something with. If you take a look at other playlist replacement programs, they use alternative methods than re-reading the playlist every time this message is fired. Its just not practical to do.
shaneh is offline   Reply With Quote
Old 14th January 2005, 10:51   #182
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
Quote:
Originally posted by shaneh
@wabiloo: Thats possible, however it would fire far too often. That message is fired far more often than is practical to do something with.
Ah, I didn't think it would fire that often, unless obviously it fires every time winamp skips a song as well...

Quote:

If you take a look at other playlist replacement programs, they use alternative methods than re-reading the playlist every time this message is fired.
Well, that's precisely my problem. The programs I know that try to do something of the sort are just crap and I end up with playlists completely out of sync, with the consequence of the external program telling me song X is playing when Winamp plays song Y. Bloody annoying!
Would you mind possibly giving me a couple of references of playlist replacements programs you know do that well, or pointers to source that explain a proper method to do so?

Many thanks!
Wabiloo is offline   Reply With Quote
Old 14th January 2005, 11:08   #183
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Mexp or whatever its called does this. It uses a trick where it just keeps 3 items in the playlist at anytime, and uses its own external playlist. It then updates the winamp playlist with the relevant 3 items whenever is necessary. (3 items for: current, previous and next).

You will be hard pressed to find a playlist replacement plugin that does it well, this is due to a limitation of winamp and not the fault of the plugin.

I would really like to see the playlist implemented in the media library, but this will never happen with development of winamp now stopped, and it simply not being practical to synch playlists with winamp in its current state.
shaneh is offline   Reply With Quote
Old 14th January 2005, 11:45   #184
Wabiloo
Member
 
Wabiloo's Avatar
 
Join Date: Sep 2002
Posts: 62
Quote:
Originally posted by shaneh
but this will never happen with development of winamp now stopped,
Are you aware of something I'm not?
There's a post on the Winamp website that denies this:
http://www.winamp.com/about/article.php?aid=10627
Wabiloo is offline   Reply With Quote
Old 14th January 2005, 11:52   #185
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Well I'll believe it when I see it. Bug fixes dont count as development IMHO. And certainly not in anyway hinting towards the kind of development required to implement any more features such as this.

The guy who wrote that post is from winampunlimited.com and isnt a winamp developer AFAIK, so Id not put much faith in something like that unless it comes from someone who would actually be doing any development.
shaneh is offline   Reply With Quote
Old 14th January 2005, 15:17   #186
inthegray
Major Dude
 
inthegray's Avatar
 
Join Date: Sep 2003
Posts: 704
Send a message via AIM to inthegray
i've reason to believe that wa is still being worked on, and will very likely see a noticeable increase in development activity in the next year.
inthegray is offline   Reply With Quote
Old 14th January 2005, 18:22   #187
herd
Junior Member
 
herd's Avatar
 
Join Date: Nov 2004
Location: Germany
Posts: 7
Dear Shaneh, I have a small suggestion:

Controlling winAmp from an external COM controller application is very easy thanks to your plugin. However, C++ Apps can encounter problems when the user closes winAmp by the UI. Any further access beyond the destruction is denied (RPC_E_DISCONNECTED) since you seem to call CoRevokeClassObject and shut down correctly.

Please consider implementing two aditional events to notify your clients of:
1. That you're about to shut down, e.g. OnAboutToTerminate() thus giving the caller a chance to cleanup before all your objects are destroyed / detached.
2. OnTerminate(). App should never get this if it did a proper cleanup.
This way, the caller can clean all memory tied to WA resources and avoid memory leaks.

TIA,

Hakan
herd is offline   Reply With Quote
Old 16th January 2005, 23:13   #188
DION03
Junior Member
 
Join Date: Jan 2005
Posts: 2
I've looked through here a bit and haven't quite found the answer I am looking for (great tool by the way). I want to work out a code to run through albums that I choose and create a log for missing tracks, or even better to create a "placeholder" mp3 in a directory and add new track to library.

The tricks:
- Name the file %artist% - %album%/%tracknumber% - %artist% - Missing Track.mp3 for metadata.
- "Missing Track" title allows for a smart view in Media Library (title = 'Missing Track').
- Go to smart view in album/artist mode and find all incomplete albums and missing tracks at your fingertips!

Why not "add seperator" or why anything?
- I have tried a custom "add seperator" to each incomplete album one by one and saving as a playlist. This works but is slow and doesn't help point out missing tracks.
- When there are too many incomplete albums and tracks to remember what needs updating.
- The aesthetics of having a track for every spot in an album, complete or not.

How does it "think"?
- What is the highest track number, according to the library?
- Is there supposed to be a track before this one?
- Is there a library entry for this track?
- If not, assume there is no file for it and create the placeholder file.
- Repeat through to track #1.

I'm not technically expert here, but I know the logic. Can anyone help? I think a lot of us could use it. I should point out that this would be for an established mostly-accurate library and should only be executed on albums you know to be largely complete.

I have tried creating blank text files and changing the extension. This serves the purpose of adding a library entry and the file did keep idv3 tags but I am sure there are other issues with this.
DION03 is offline   Reply With Quote
Old 17th January 2005, 01:06   #189
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
@herd: I will add that in when I tidy it up and decide on how to release later versions and open source it etc. I need to read up on the standard practice of modifying COM components after they are released. I dont want people to have to recompile their programs for every new release, or have them crash when using the wrong one etc, so I will need to do it right.

I worry though that sending that event then effectively shutting down may cause problems. As the event source will have disappeared by the time the target gets the notification. Threading, message pumping, apartments etc all come into play and it becomes a bit of a nightmare.

The proper solution is to actually prevent winamp from shutting down if there are any connections. msnmessenger does this for example when outlook is still open. I could do this in winamp too. Will need to look into it.


@DION03: not too sure what you going on about :P Im guessing you just want to create placeholder .mp3 files for missing tracks from an album somehow.

Unfortuantly AW doesnt currently allow you to just add stuff to the library, though you can create files. You could then send a window message to the ML to rescan watched directories after you are done I suppose. (note, loading a file with LoadFile then modifying a ml metadata value may add the item to the ml too).

The best way would probably be to make a sendto_ script, and have it look at the album of the selected file. Then query the ML for that album, and sort the results by track. (or just sort the selected songs by track without doing a query if you want to select the actual album yourself).

Then just step through each one and put in a placeholder file/s if the track number increments by more than one.
shaneh is offline   Reply With Quote
Old 19th January 2005, 07:56   #190
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
The plugin doesn't work anymore

Hmm. Since a couple of days, the plugin doesn't work properly anymore. I have two startupscripts (that log all the songs that are played) - these work fine. But all the scripts I want to run from the playlist or the Media Library (e.g. randomize selection and increase playcount) don't work anymore
I don't know what could be wrong - I haven't removed DLL's from the plugin folder or something like that.

Can someone suggest how I can fix this problem?
CaAl is offline   Reply With Quote
Old 19th January 2005, 08:56   #191
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
What about implementing more structured scripts like those WSF files. Using WSF files are much more robust than using plain scripts. You could create a WSF like format for use with AW (e.g. AWSF - ActiveWinamp Script File). This file will contain XML tags like '<script language="VBScript">' and '<JOB id="id">' so you could put more scripts inside one file. You could also specify special attributes/tags for defining custom menu items and behaviour. Here is an example of what an AWSF file would look like:
code:

<awsf>
<actions>
<action event="onstartup" trigger="startup1" />
<action event="onstartup" trigger="startup2" />
</actions>
<menu>
<menuitem trigger="sort_playcount">Sort files after playcount</menuitem>
</menu>
<sendtoitems>
<menuitem trigger="copytofolder">Copy to MP3-player</menuitem>
</sendtoitems>
<script id="sort_playcount" language="VBScript">
' do work here
</script>
<script id="startup1" language="VBScript">
' do work here
</script>
<script id="startup2" language="VBScript">
' do work here
</script>
<script id="copytofolder" language="VBScript">
' copy to mp3 player...
</script>
</awsf>



PS! Can some moderator edit neFAST's post so it doesn't expand the forum page so much?
saivert is offline   Reply With Quote
Old 19th January 2005, 09:20   #192
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Re: The plugin doesn't work anymore

Quote:
Originally posted by CaAl
Hmm. Since a couple of days, the plugin doesn't work properly anymore. [..]
Can someone suggest how I can fix this problem?
I found the solution: a couple of days back I've set the option "use advanced title formatting when possible" (under general prefs/titles) to off. Now I switched it back on, and the scripts all work fine.

Seems a bit weird though, that this was the couse of the problems...
CaAl is offline   Reply With Quote
Old 21st January 2005, 18:24   #193
Thunder Pussy
Feed me a stray dog
(Major Dude)
 
Join Date: Oct 2004
Posts: 1,122
Hi, I need help (again). I've just added my my out-of-rotation folder to the ml db to take advantage of ml caching in dynamic library. I'm having to edit all of my scripts to accomodate this. There are 3 scripts I use that follow the same format, and I need to edit them so that they include only songs from "E:\Music\". How do I fix this? I get errors when I add filename has E:\Music AND... Thanks very much.





Randomize
x = playlist.getselection()
if ubound(x,1) > 0 then
mlq = medialibrary.runqueryarray("artist = """ + x(1).artist + """")

i = 0
for each track in mlq
i = i + 1
swapitems mlq(i), mlq(Int((ubound(mlq,1)) * Rnd + 1))
next

for each track in mlq
if strcomp(track.filename, x(1).filename) <> 0 then
track.insert(x(1).position)
end if
next
end if
quit

sub swapitems(ByRef val1, ByRef val2)
set temp = val2
set val2 = val1
set val1 = temp
End Sub
Thunder Pussy is offline   Reply With Quote
Old 26th January 2005, 16:43   #194
katemonster
Junior Member
 
Join Date: Aug 2004
Posts: 5
Any news on a website to post scripts people have written? I'm trying to figure out how to do this from scratch basically, and I think it would help me to have more scripts to look at. As it is, I don't even know that what I want to do is possible--would it be possible to write a script to generate a playlist choosing tracks weighted by rating and various other factors? Basically, a smarter shuffle...
katemonster is offline   Reply With Quote
Old 27th January 2005, 07:52   #195
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Hi Kate,

When you read the messages in this thread, you'll encounter some scripts which might help you.

I don't think such a smart shuffle thing is (easily) possible - I've been working on it myself for quite some time. The problem is that you need to make some kind of database with your songs and their ratings, because reading the ratings from the MP3tags will work too slow (and I'd like more than 5 categories in my rating).
So you have to write some dataexport and dataimporting scripts, etc. It can be done, but it's a lot of work...
CaAl is offline   Reply With Quote
Old 27th January 2005, 08:20   #196
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I have some web space and domains etc, but just lack of time to do up a site properly.

A weighted shuffle wouldnt be impossible, just require a bit of work. The rating info isnt that difficult to extract if its stored in the media library, just do a query and look at the ratings, playcount last played etc and work with that.

The easiest way to do it is probably to turn shuffle off, then fill the playlist with items based on whatever algorithm you choose. The algorithm would be the most difficult part.

Otherwise you can do a sort of 'party shuffle' thing, where you just have a few items in the playlist, and add new ones as the songs change.

You can get media library items by simply doing:

mlitems = MediaLibrary.RunQueryArray("Rating > 0")
'sort mlitems based on criteria
for each song in mlitems
song.enqueue
next

As you can see, the algorithm to sort/mix/whatever the items would be the most difficult part.

I have a sort of weighted shuffle thing I picked up somewhere a while back. Dont think it works too well, but you can take a look at it:

Dim songlist(), i, rndtotal, lasttrack
Randomize

Sub Application_ChangedTrack
playlist.deleteindex playlist.position - 1

ReDim songlist(playlist.count - 1)
i = 0
for each song in playlist
songlist(i) = song.rating
i = i + 1
next

i = 0
ratingtotal = 0

'calc average
for each song in songlist
ratingtotal = ratingtotal + songlist(i)
i = i + 1
next
ratingavg = Int(ratingtotal / ubound(songlist))
i = 0
rndtotal = 0
for each songr in songlist
if songlist(i) = 0 Then
songlist(i) = ratingavg
End if
rndtotal = rndtotal + songlist(i)
i = i + 1
next

rval = Int((rndtotal - 0 + 1) * Rnd + 0)
runningtot = 0
i = 0
for each songr in songlist
i = i + 1
runningtot = runningtot + songr
if runningtot >= rval Then
playlist.position = i
play
lasttrack = i
exit for
end if
next
End Sub
shaneh is offline   Reply With Quote
Old 30th January 2005, 18:04   #197
Crestronite
Junior Member
 
Join Date: Jan 2005
Posts: 6
A real newbie Q. I am trying somewhat succesfully to use ActiveWinamp from VB6. Most things are working but I wish to add a named file eg "C:\test.mp3" to a specific place in the playlist and then go on to manipulate the playlist position so it is played, and then delete it and resume. So adding to the end will be fine.I really don't want that track to become part of WinAMPs media library either. But I am struggling on how to add the named file (in VB6) not as VBscript. It would be most appreciated if someone could quickly show me how ??

Also if anyone has any more extensive VB6 code using ActiveWinamp they could share as a learning exercise that would be great.

Chris
Crestronite is offline   Reply With Quote
Old 31st January 2005, 00:46   #198
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I dont feel like installing VB6 on my machine, but AFAIK its not much different from vbscript at least in syntax.

To do that in vbscript, you would do something like:

mi = loaditem "C:\test.mp3"
mi.enqueue
oldpos = playlist.position
playlist.position = playlist.count
play
playlist.position = oldpos
playlist.deleteindex playlist.count

Edit: If youd like to not delete the item until it is done playing, you would need to trap the play state changed or song changed event, and then delete the item. However winamp will continue playing the item even though its not in the playlist. Its kinda weird though, and will screw up a few things that get current playing file info based on the current playlist position in wianmp. IMHO it is a fault in winamp.
shaneh is offline   Reply With Quote
Old 31st January 2005, 07:11   #199
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
shaneh's ActiveWinamp plugin is actually an excellent scripting platform for Winamp. I have had some time experimenting with it and you can actually convert a lot of small plugins (dll files) into scripts for ActiveWinamp. If you ever used the "Find in Explorer" plugin to get a new item in the playlist context-menu to locate a file in the Explorer you may now do this as an ActiveWinamp script:

VBScript
code:

Option Explicit
Dim wsh, sel
sel = Playlist.GetSelection
Set wsh = CreateObject("WScript.Shell")

If UBound(sel) = 1 Then
wsh.Run "explorer.exe /select," & sel(1).Filename
End If

Quit 'end script



PS! And please... what's all those WIDE posts for? Keep your CODE sections broken into multiple lines. Use the underscore to split lines in VBScript. Like:
code:

Dim x
x = Playlist.GetSelection

For y = ubound(x) To 1 Step -1
set sep = LoadItem("x:-----" + _
x(y).Album + _
"-------------------.x")
sep.Insert(CInt(x(y).position) -_
1)
Next

Quit



And please use capitalization when writing VBScripts. It's much easier to read then. Refer to the VBScript coding style info from Microsoft.
All lowercase isn't neccessary in order to get the script running. shaneh uses Mixed case in his documentation so why shouldn't we?
saivert is offline   Reply With Quote
Old 31st January 2005, 15:19   #200
Crestronite
Junior Member
 
Join Date: Jan 2005
Posts: 6
Quote:
Originally posted by shaneh
I dont feel like installing VB6 on my machine, but AFAIK its not much different from vbscript at least in syntax.

To do that in vbscript, you would do something like:

mi = loaditem "C:\test.mp3"
mi.enqueue
oldpos = playlist.position
playlist.position = playlist.count
play
playlist.position = oldpos
playlist.deleteindex playlist.count

In VB6 I have a global declaration
Dim WithEvents aWinAMP as ActiveWinamp.Application

In my Form Load() I have
Set aWinAMP=CreateObject("WINAMPCOM.APPLICATION")

Most things seem to work ok including the event callback

In a different subroutine I have
Dim mi as MediaItem
mi=aWinAMP.LoadItem("C:\temp.mp3")
mi.enqueue

... etc

but the loaditem assignment errors with invalid use of property - - although it looks as though the right hand side indicates it returns a MediaItem , I think it actually returns a string. I guess I'm being really stupid here ?

mi= aWinAMP.Loaditem "C:\temp.mp3" is not a valid syntax

msgbox aWinAMP.LoadItem("C:\temp.mp3") gives a "C:\temp.mp3" message and the filename is not checked in anyway as existing as it works for anything.

Chris

EDIT: AHHH - and the light went on... ;-)

Set mi=aWinAMP.LoadItem("C:\temp.mp3")

DUH ! Chris
Crestronite is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump