Old 21st September 2004, 07:43   #81
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
A simple example in MFC/Cpp which uses the component. Be careful about writing anything significant at this point in time, as functions and library names etc are expected to change.
Attached Files
File Type: zip cppsample.zip (85.5 KB, 700 views)
shaneh is offline   Reply With Quote
Old 21st September 2004, 08:12   #82
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
How do you get the so called "script helper" loaded as a Media Library plugin? gen_script1.dll does not export winampGetMediaLibraryPlugin.
saivert is offline   Reply With Quote
Old 21st September 2004, 09:14   #83
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
There are IPCs to add and remove media library plugins. An ML helper plugin was necessary in order to get the 'send to' items.
shaneh is offline   Reply With Quote
Old 21st September 2004, 13:08   #84
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
You mean through this:
code:

These are reverse engineered, so may not be supported
too well or entirely accurate.


long libhwndipc = (LONG)SendMessage(hwndWinamp,
WM_WA_IPC, (WPARAM)"LibraryGetWnd",
IPC_REGISTER_WINAMP_IPCMESSAGE);



And then using the standard ML_IPC_* like:
code:

/* pass a winampMediaLibraryPlugin *.
Will not call plugin's init() func.
YOU MUST set winampMediaLibraryPlugin->hDllInstance to NULL,
and version to MLHDR_VER
*
#define ML_IPC_ADD_PLUGIN 0x0750
#define ML_IPC_REMOVE_PLUGIN 0x0751 /* winampMediaLibraryPlugin *
of plugin to remove. Will not call plugin's quit() func */

saivert is offline   Reply With Quote
Old 21st September 2004, 13:14   #85
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Yep
shaneh is offline   Reply With Quote
Old 21st September 2004, 13:42   #86
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
That's very assuring!! Now I can finally get on the train home (I'm sitting at school). Bye, will be back tomorrow...
saivert is offline   Reply With Quote
Old 22nd September 2004, 06:57   #87
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
awww....

what a waste of time :P

It reminds me of a plugin I intended to write a while back but never did. One of these days I will... Should be pretty good if it works out. Will see how I go for time.

---------
Const ForReading = 1

Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.OpenTextFile("C:\art.txt", ForReading, True)

Do While MyFile.AtEndOfStream = False
artline = MyFile.ReadLine
if artline = "" then
artline = " "
end if
set sep = LoadItem("x:" + artline + ".x")
sep.Enqueue
Loop

MyFile.Close

quit
Attached Images
File Type: jpg teddy.jpg (77.7 KB, 588 views)
shaneh is offline   Reply With Quote
Old 22nd September 2004, 09:20   #88
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
Oh what a cute little teddy...

Maybe you could write a quote of the day script too, that will randomly drop lines from a quote file and scatter it around in the playlist. Would be very similar to the teddy script.
saivert is offline   Reply With Quote
Old 22nd September 2004, 10:04   #89
electricmime
Major Dude
 
Join Date: Mar 2004
Posts: 991
in the atfe thread, i thought it would be cool if you could save atf strings, and change them whenever you want(from the playlist window) would that be possible through scripts(and if it is, would it be possible to update all the files once you change atf strings)

There is no reset button on life... but the graphics kick ass
electricmime is offline   Reply With Quote
Old 22nd September 2004, 11:56   #90
FarmerDave
Junior Member
 
Join Date: Sep 2004
Posts: 2
shaneh - excellent work - I was casting about for a way for controlling winamp on my server - didn't like any of the existing stuff out there, so started writing my own using .net remoting - this has saved me a *ton* of effort, thanks!

One request, or maybe I'm just missing it - can you add a "current playback status" property (i.e., Stopped, Paused, Playing)?

Thanks again,
FarmerDave
FarmerDave is offline   Reply With Quote
Old 22nd September 2004, 21:27   #91
neFAST
Member
 
Join Date: Sep 2004
Location: Montreal
Posts: 56
Send a message via ICQ to neFAST
I'm still a little off-topic but I just want to say that the rand Items plugin always insert the 2nd song of an album !

I don't really understand the last line of the code (CInt(idxs(Int(ubound(idxs)+1 * Rnd)))):
code:
Rand = Int((Dict1.Count + 1) * Rnd)
idxs = Split(itms(Rand), ":", -1, 1)
Rand2 = CInt(idxs(Int(ubound(idxs)+1 * Rnd)))
mlq(Rand2).enqueue


But I think the problem is here.

any idea ?

[edit]
me and my beloved brain have found the answer :

I juste changed the brackets and +1 in the random
code:

Rand = Int(Dict1.Count*Rnd+1)
idxs = Split(itms(Rand), ":")
Rand2 = Int(idxs(Int(ubound(idxs)*Rnd+1)))
mlq(Rand2).enqueue


Last edited by neFAST; 22nd September 2004 at 22:08.
neFAST is offline   Reply With Quote
Old 23rd September 2004, 09:12   #92
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Plenty of changes. The library is now named ActiveWinamp instead of gen_script1Lib.

+ Many of the methods now return strong types rather than variants. Changed types used internally and externally quite a bit, should work better.

+ Fixed a serious problem with closing scripts.

Application:
+SendMsg() - does a sendmessage to the main hwnd
+PostMsg() - does a postmessage to the main hwnd
+UpdateTitle()
+RunScript(BSTR)
+Property PlayState
+Property Hwnd
+Property Panning
-Events:
+ChangedVolume()
+ChangedStatus()
+PlaybackEOF()

Playlist:
+SendMsg()
+PostMsg()
+Property Hwnd

MediaLibrary:
+SendMsg()
+PostMsg()
+Property Hwnd

You can use the sendmsg and postmsg methods to do many of the other actions not available natively to the plugin.
Attached Files
File Type: zip gens.zip (91.5 KB, 613 views)
shaneh is offline   Reply With Quote
Old 23rd September 2004, 09:19   #93
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Much more interesting sample in MFC, demonstrates how to do ml queries and work with the arrays. The previous example wont work anymore due to the changes in gen_script1.
Attached Files
File Type: zip cppsample.zip (89.2 KB, 576 views)
shaneh is offline   Reply With Quote
Old 23rd September 2004, 09:45   #94
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
I'm now also using a "helper ML plugin" in my plugin NxS Balloon Tip. And I also get the data from the Media Library instead of using IPC_GET_EXTENDED_FILE_INFO.

ON-TOPIC
I'm writing documentation for your plugin, that means all the methods functions described and a couple of guidelines. Hope you'll like it...
saivert is offline   Reply With Quote
Old 23rd September 2004, 09:49   #95
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Sounds good saivert. I will eventually get around to writing up the .idl file properly, so that when using it within VB or othewise using the type library, there will be some better help contexts for the methods/properties.

If you want you can fill in this idl file, or just use it as a reference.
Attached Files
File Type: zip gidl.zip (2.6 KB, 644 views)
shaneh is offline   Reply With Quote
Old 23rd September 2004, 10:20   #96
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
Docs

I actually didn't need the .idl file as I can use OLEView (bundled with VC++) to de-compile the .tlb file into a .idl file again. I will not fill in the idl file however becuase I am writing documentation for use by anyone, and not just people who can read idl file like it was a novel.

It will be more structured and have a tree-like form with examples along the way.

Here is the first draft:
Attached Files
File Type: zip scriptdocs.zip (3.2 KB, 897 views)
saivert is offline   Reply With Quote
Old 23rd September 2004, 10:53   #97
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Ok looks good saivert.

Although there is still heaps to do with this plugin, its nearing a point where I am happy to release it and the names and dispids etc will all remain fixed. I need to add plenty of stuff for dynamically adding hotkeys/ menu /items /arguments to scripts etc. But that is mostly for script hosting stuff and can be added over time without affecting the rest of the functionality.

Ive been holding off doing any docos etc until I set the interfaces in stone. But it currently provides most of the typical stuff you would use from an external program through COM, so I may release it.

The reason for editing the .idl file is not for people to read that, but it is used to compile the type library. The help strings are part of this library, in this way the object is self documenting. When using it in VB or any other environment, the help strings that are put in this .idl file appear in the object browser. A good IDE will also provide little tool tip texts with these help strings when using a method from the type library.

(the position property in the playlist is both set/get).
shaneh is offline   Reply With Quote
Old 23rd September 2004, 15:43   #98
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Fixed a leak problem with arrays (runqueryarray/getselected/getsendtoitems).

Fixed issue with getting meta data from items not in the ml.

Fixed sample client app
Attached Files
File Type: zip gens.zip (91.6 KB, 626 views)
shaneh is offline   Reply With Quote
Old 23rd September 2004, 15:44   #99
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
sample app

The mfc sample app. Works much better.
Attached Files
File Type: zip cppsample.zip (45.1 KB, 577 views)
shaneh is offline   Reply With Quote
Old 24th September 2004, 09:31   #100
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
ActiveWinamp Scripting Reference Rev. 1

All done!

I hope it will be included in future releases of ActiveWinamp.

Note: The ZIP also contains two scripts i have written, check em' out

Here it is:
Attached Files
File Type: zip activewinamp_scripting_reference_rev1.zip (4.2 KB, 732 views)
saivert is offline   Reply With Quote
Old 28th September 2004, 15:29   #101
John Baker
Junior Member
 
Join Date: Sep 2004
Posts: 7
Randomize list?

Can a script be used to randomize a playlist?
John Baker is offline   Reply With Quote
Old 28th September 2004, 18:18   #102
electricmime
Major Dude
 
Join Date: Mar 2004
Posts: 991
theres already one for randomize selection included, and if you want to randomize the entire thing in winmap click misc->sort->randomize list

but if you really wanted to make the script, you could just edit randomize selection

There is no reset button on life... but the graphics kick ass
electricmime is offline   Reply With Quote
Old 28th September 2004, 21:03   #103
John Baker
Junior Member
 
Join Date: Sep 2004
Posts: 7
I'd like to automate it so that it can be scheduled to load a playlist and randomize it. Currently, I am simply scheduling it as a task. If I could run a script instead of a playlist that would randomize after load that would be ideal.
John Baker is offline   Reply With Quote
Old 30th September 2004, 13:03   #104
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Scripts now run in a separate thread. This allows you to to lengthy operations such as connect to remote web sites or databases etc without locking up winamp. Note that lengthy operations within the Application object itself (basically all exposed methods) will still lockup winamp due to the way it is implemented. (in particular ml queries which take a long time). But when the script isn't 'inside' an exposed method winamp will still be responsive. (ie when calling methods on other objects or other execution which doesnt spend time in calls to the exposed methods).

Also fixes some mem leak issues with ml queries.

The quit method now quits when you call quit rather than just signalling that it should quit when the script is finished. Note there may be some occasions where it doesnt quit immediately and may continue executing for a couple more lines, so structure your code accordingly until its fixed.

Theres likely to be a few bugs but it seems to run ok so far.


@John Baker: That would probably require an event which fires on opening of new items. No such event exists yet.

You can however use this script:

SendMsg 273, 40029, 0
playlist.postmsg 273, 40212, 0
quit

And assign it a hotkey or something. Then use this to open playlists. It sends the 'open file dialog' command to winamp, then the 'randomize playlist' to the playlist after the dialog is closed.
Attached Files
File Type: zip gens.zip (92.0 KB, 578 views)
shaneh is offline   Reply With Quote
Old 30th September 2004, 13:43   #105
FarmerDave
Junior Member
 
Join Date: Sep 2004
Posts: 2
shaneh - thanks again for this plugin, my remote is working great. I've still got a bunch of stuff to do - software is never truly "done", eh?

Anyway, I turned a friend onto your plugin, and he's asking if there's a way to get to the album art (even just a filename) using this OM. I didn't see one, so I'm passing the question along. If not, do you have any plans to expose such a property/method?

Thanks,
FarmerDave
FarmerDave is offline   Reply With Quote
Old 1st October 2004, 00:50   #106
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
@Farmerdave: You can just use

mi = playlist(1)
fn = mi.ATFString("%dir%") + "\Folder.jpg"

Or various other combinations. I personnaly use a script like:

x = playlist.getselection()
if ubound(x,1) > 0 then
set wso = CreateObject("Wscript.Shell")
pos = InStr(8, x(1).filename, "\", 1)
mpath = Left(x(1).filename, pos)
mpath = Mid(mpath, 8)
wso.run "C:\Mp3\downart """ & mpath & """"
end if
quit

In order to download mmissing albumart using a tool which connects to the web and downloads cover images. downart is a batch file which changes directories and calls mp3albumartdownloader etc.

If you are talking about getting the cover art out of the id3 tag, I think id3lib comes as a COM library as well. You would need to do something like:
id3o = CreateObject("ID3Lib.Application")
id3o.loadtag mi.filename
pic = id3o.getcover
or whatever. I may put id3 support in this plugin, but I think external support may be a better option.

edit: see http://forums.winamp.com/showthread....68#post1485468
for an example of using id3com to access id3 tags.

Last edited by shaneh; 1st October 2004 at 02:52.
shaneh is offline   Reply With Quote
Old 2nd October 2004, 02:17   #107
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
example script

To demonstrate a lengthy web service type script and the multi-threading support, heres a neat little script. It will query Audioscrobbler for the top songs by a song selected in your playlist and attempt to enqueue them.

Prob got a few bugs, but you get the idea.


-------playlist_enqueue artists top songs as.vbs---------

dim xmlhttp, art, dict1, mlq

x = playlist.getselection

if ubound(x) > 0 then

Set Dict1 = CreateObject("Scripting.dictionary")
Dict1.CompareMode = 1
art = x(1).artist
mlq = medialibrary.runqueryarray("artist = """ & art & """")

i = 1
for each song in mlq
dict1(song.title) = i
i = i + 1
next

set xmlhttp = CreateObject("Msxml2.XMLHTTP.4.0")
set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0")

xmlhttp.Open "GET", "http://www.audioscrobbler.com/music/" + art, false
xmlhttp.Send

res = xmlhttp.responsetext
xmldoc.validateonparse = false
xmldoc.resolveexternals = false

ns = "xmlns:asx='http://www.w3.org/1999/xhtml'"
xmldoc.setProperty "SelectionNamespaces", ns

xmldoc.loadxml replace(res, "&", " ")

If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox(myerr.reason + " " + myErr.srctext)
quit
end if

set nl = xmldoc.documentelement.selectSingleNode("asx:body/asx:div[@id='main']/asx:div[@class='content']/asx:table[@class='topn']")
set tl = nl.selectNodes("asx:tr")

for each song in tl
idx = dict1(song.selectSingleNode("asx:td/asx:a").text)
if (idx > 0) then
mlq(idx).enqueue
end if

next

end if
quit
shaneh is offline   Reply With Quote
Old 3rd October 2004, 05:41   #108
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
+ Hopefully fixed a couple problems introduced by threading
+ Scripts with certain types of errors quit properly now
+ The Quit function should work ok without race problems
+ Added a 'position' property to get the current track position
+ A couple example scripts
Attached Files
File Type: zip gens.zip (93.8 KB, 602 views)
shaneh is offline   Reply With Quote
Old 3rd October 2004, 06:57   #109
electricmime
Major Dude
 
Join Date: Mar 2004
Posts: 991
so.. is it possible to make a script that changes your atf string?

There is no reset button on life... but the graphics kick ass
electricmime is offline   Reply With Quote
Old 3rd October 2004, 07:46   #110
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I guess you could write a script which reads in winamp.ini and modifies the ATF setting in there, winamp supports no other means of changing this setting. You may need to restart winamp to get this setting to stick, Im not sure. Then you would need to re-read in all the titles for the new setting to reflect in the playlist, this can be done by a 'select all, read extended info' button emulation bit of script, but it would be slow for a lot of items.

Its not something that you can just quickly switch between different settings. Frankly I dont think its too practical.
shaneh is offline   Reply With Quote
Old 4th October 2004, 23:58   #111
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
update

Added Arguments and Description(rw) properties to SiteManager.

Description allows you to set/get the text used in the running scripts dialog.

Arguments allows you to obtain the arguments passed by 'RunScript', which now takes an 'arguments' paramater.

The running scripts dialog lets you pass arguments to opened scripts.

Allows you to run scripts from the playlist through 'script:\' items. You can also pass arguments, check out the pause and closewinamp examples to see what I mean.

(scripts run in this manner will get a "-pos=x" argument indicating the position in the playlist it was run from. You should use this instead of playlist.position because it is threaded and may have changed by the time you read it in).

Un-done some thread fixes which werent needed.

Fixed 'Quit' a bit more, plus some problems with scripts with errors not quitting properly.

A few more example scripts.
Attached Files
File Type: zip gens.zip (98.3 KB, 585 views)
shaneh is offline   Reply With Quote
Old 9th October 2004, 00:46   #112
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
+Fixed a problem with getting events from the object in web pages. The net effect is you can now receive events properly in HTML pages. This is demonstrated in a simple notify.hta application. (note that this plugin is not marked safe for scripting, so you cannot just run this from random internet web pages for security reasons).

+Fixed a crash problem with getting meta data from files which arent in the media library.
Attached Files
File Type: zip gens.zip (99.0 KB, 630 views)
shaneh is offline   Reply With Quote
Old 10th October 2004, 11:00   #113
DAVOR
Junior Member
 
Join Date: Aug 2003
Location: Croatia
Posts: 32
Help needed

(sorry about my english)

Shaneh,
the "gen_script1.*" and other files are in my winamp5 dir.
Scripts ar there too. How do I start a script. When I Dbl_Click a script it return me an error. See the picture. It happens on each script.

How do I start it????
Attached Files
File Type: zip shaneh help me.zip (53.6 KB, 524 views)
DAVOR is offline   Reply With Quote
Old 10th October 2004, 11:03   #114
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I suspect you do not have the media library installed and loaded? Make sure you do, and configure it to load at winamp start.

If you do not wish to use this, the other scripts which dont use the media library may work, but Im not sure. Its best just to enable the library, Hope it works out ok.

EDIT: oh, you are trying to run the scripts through windows... run them from winamp via the 'scripts' right click menu item in the playlist.

You can write scripts that run externally, but most of the scripts included were not written like this.

Just adding :
set wa = CreateObject("ActiveWinamp.Application")
and "wa" in front of all the method calls and properties, and remove the 'quit' call and the scripts should work ok externally.
shaneh is offline   Reply With Quote
Old 10th October 2004, 11:13   #115
DAVOR
Junior Member
 
Join Date: Aug 2003
Location: Croatia
Posts: 32
Winamp 5.04 with media l. is loaded I Dbl click any of scripts, the error is still there.
Attached Images
File Type: jpg shaneh help me.jpg (72.9 KB, 503 views)
DAVOR is offline   Reply With Quote
Old 10th October 2004, 11:24   #116
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
As stated above, those scripts are not designed to be run externally, although it is possible.

If you are planning on using this to extract the selected files from an external app, I would advise importing 'ActiveWinamp.Application' and calling methods on it directly, namely playlist.getselected(), which returns an array of mediaitems. There is a cpp example in this thread, but it can be adapted to VB easy enough.
shaneh is offline   Reply With Quote
Old 15th October 2004, 13:58   #117
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Is there a way to work with a rating-system that support more levels than the standard-ID3V2 5-star system? (Preferably, ratings between 1 and 100).
I'd like it to be possible to set these ratings in Winamp - not some external program - and, if possible, also save this info in the ID3 tag.
I've tried some things, but it seems that Winamp deletes custom ID3V2 tags when you change e.g. the title of a song - which is obviously annoying.
Anyone?
CaAl is offline   Reply With Quote
Old 15th October 2004, 15:36   #118
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
The standard id3v2 system is actually 0-255. Winamp uses a 5 star system in its ML. I dont believe I set a limit in this plugin, so you should be able to set the rating to whatever you like. Dont expect it to be displayed in the ML of course, it uses ***** and theres nothing you can do about that.

If you take a look at the ID3 rating export/import script I wrote, you could modify it to write whatever rating number you like to the field. I currently just take the rating and multiply/divide it by 51 in that script which is what WMP does. But again, the ML will ignore whatever you write to this tag, the ML does not read in rating data from id3 tags by default.
shaneh is offline   Reply With Quote
Old 18th October 2004, 09:48   #119
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Thanks for the answer. Another question:

Is it possible to turn some kind of function on/off? I want a script that executes some actions each time a song is played, but only when I am in "perform this on each song-mode". When I'm not in that mode, it should do nothing. How can I do that?
CaAl is offline   Reply With Quote
Old 18th October 2004, 11:21   #120
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Is it also possible to have some script to be executed every X minutes? (Just like the media library is re-read every Y minutes)
CaAl 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