Old 1st February 2005, 00:53   #201
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Yep, I forgot the brackets. I was going to edit it in but I figured youd work it out, the example in the help file for loaditem uses brackets.

You should be using 'activewinamp.application' not winampcom.application. But if you can get loaditem to work, I guess you are using the correct one.

I thought the 'Set' may have been needed, but I think its not necessary under vbscript.
shaneh is offline   Reply With Quote
Old 1st February 2005, 07:13   #202
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
I have made an update to your ActiveWinamp examples. Here it is:

NxS-ActiveWinamp-stuff-Setup.exe
saivert is offline   Reply With Quote
Old 1st February 2005, 11:33   #203
Crestronite
Junior Member
 
Join Date: Jan 2005
Posts: 6
Quote:
Originally posted by shaneh
You should be using 'activewinamp.application' not winampcom.application. But if you can get loaditem to work, I guess you are using the correct one.
Sorry yes - I was using the right one - just typed the wrong one in the message as I was trying a couple of different approaches. All is working now.

I have been trying three possible scripting solutions for my projects all of which have different strengths and weaknesses. ActiveWinAMP is my favourite in terms of most features and responsive developers (thanks !) - but I do need control of multiple instances on one machine (see thread http://forums.winamp.com/showthread....hreadid=206384 ) . This is because I use six channel (surround sound) audio cards divided into 3 stereo pairs each driven by a different WinAMP instance for 3 audio zones. I take it from your reply that launching WinAMP using the optional "class" parameter as Lion12 was doing earlier in this thread will not help either - even if I ensure my WinAMP instances are all up and running prior to my application. I am guessing I can't control which winamp instance I'm connecting to or even 'step' through multiple instances to identify a particular one by an ID or by recovery of the class name or something. ..

Chris
Crestronite is offline   Reply With Quote
Old 1st February 2005, 11:53   #204
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
snipped.
/EDIT: Ignore that ramble.

Im looking into adding proper multiple instance support. Will see how it goes. I'll upload a test version here. I will need to disable a few other things to get it working, but it may be useful for you to play with.

Last edited by shaneh; 1st February 2005 at 12:40.
shaneh is offline   Reply With Quote
Old 1st February 2005, 13:18   #205
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Heres a rough version of AW which supports multiple instances a little better. Note however its not fully tested.

Also note, it uses the REGCLS_SINGLEUSE registration in the ROT. What this basically means is, the active instance of the object is registered in the system, but once an external application grabs that object it disapears in the table.

So, you cannot re-grab the ActiveWinamp object once you have used it externally. ie, the registration assumes a new copy of the .exe will be started for every 'object grab', and the .exe will be basically terminated once finished. If this isnt the case, it causes problems when you go to use AW again, either from the same application or a different one. So you have to keep the reference around, lose it, and you have to start another copy of winamp and get another one.

So basically, this version of AW is for multiple use only, and just for playing with. I might look into a better solution using monikers and window classes.
Attached Files
File Type: zip tempaw.zip (85.3 KB, 614 views)
shaneh is offline   Reply With Quote
Old 6th February 2005, 14:19   #206
Crestronite
Junior Member
 
Join Date: Jan 2005
Posts: 6
Hi.. thanks for the changes you made here, this is working well for me in separating my instances, so I'm half way there. I have multiple instances running and controlled OK :-)

As I was previously set up I had several WinAMP folders and I used to launch each WinAMP individually , from its own folder and the preferences were set such that each used different output options effectively feeding the audio to different zones. How might I accomplish that using this type of solution as my instances are identical, would I in some way be able to load a different ini file in each instance perhaps , or set the output somehow ?

Alternatively if I wish to control an already running instances of WinAMP I think you are saying that is going to be not possible as I cant get at the object. I was just thinking of launching my 3 independant zones and picking them up that way.

Chris

<edit> What I think I shouldn't be doing is using 'CreateObject' and creating a new object but instead picking up one of the mutiple existing instances perhaps using GetObject.

Last edited by Crestronite; 6th February 2005 at 14:55.
Crestronite is offline   Reply With Quote
Old 6th February 2005, 17:36   #207
Crestronite
Junior Member
 
Join Date: Jan 2005
Posts: 6
Yes - just needed to use GetObject - and I can pick up the already existing instances so this is very suitable for what I need, (although as you say it can only run once without having to restart the WinAMPs) .. Many thanks

Chris
Crestronite is offline   Reply With Quote
Old 7th February 2005, 00:50   #208
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I am working on a new implementation which will allow you to hopefully "GetObject" using the window class name of the started winamp. Im still looking into it but hopefully it will work ok.

I think that version I posted here is a bit broken, events may not work properly with it. Basically its just for playing with until I get a proper version released.
shaneh is offline   Reply With Quote
Old 12th February 2005, 00:48   #209
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
First off, let me say THANK YOU for developing an activex COM object for Winamp. I had been struggling for some time with WinampCom. While this did the trick initially, it has limitations with regards to creating multiple instantiations. In my application, the com object resides on a server and is called by clients. If a client's session was terminated, the COM object remained. Subsequent client calls spawned new instantiations, and then the COM object stopped working. There is no way to get a handle to an existing object instantiation that could find with winampcom. This was a show stopper and I had almost given up on this project, when I found your plug-in posted.


So I for one appreciate the single instantiation operation. I am going to run some tests to see what happens when a client session terminates (hopefully it will work.)

One small suggestion: I got the object up and running very quickly for play, stop, pause, etc., assuming I had used the UI to load a playlist. But I struggled with trying to get a new playlist loaded with the com object. I had tried Loaditem, Getitem etc, and several combinations. After running through this thread a few times, I finally found the missing piece, the enqueue method needs to be called after the load. I'm not a winamp power user, so this was extremely non-intuitive for me. (Maybe thats just me) A little bit of text in the help file or an enqueue method example would have helped me. I couldnt find any samples that showed a new playlist being loaded.

I'll keep plugging at this to see if it solves my problem, but initial tests look promising.
JohnKane is offline   Reply With Quote
Old 12th February 2005, 01:29   #210
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Yes, enqueue is what you want.

LoadItem is just a way of creating a MediaItem and setting the filename to the one you specify. A MediaItem is essentially a representation of a file, which also caches meta data about that file if and when you request it. Consider LoadItem to be the class factory or constructor if you are familiar with OOP.

Once you have that MediaItem, you can call the various Winamp IPCs that require a filename, such as IPC_PLAYFILE, and the filename that is used is the one thats contained within the MediaItem in question.

The use is a bit different to WinampCOM, which is basically just a proxy for the API calls. ActiveWinamp was designed to be a little more 'object orientated' which leads to a better design in the long run IMHO. (ie, it lets you have an array of mediaitems and enqueue the ones you want etc instead of having to maintain your own array of filenames) People familiar with OOP should hopefully find it relatively intuitive. However coming from WinampCOMs design I can understand it may seem awkward.

I will be retooling the help file a bit in the next release with some more helpful information other than just a reference. Its currently not much more than a re-generation of the typelib with a couple lame examples, a couple of which are broken

The Enqueue method was used to represent the IPC_PLAYFILE API 'call', because that is what winamp essentially does with the file passed.

With this is mind, if winamp were able to enqueue playlist files (.m3u) via this API call, you could simply do:

set mi=loaditem("c:\pls.m3u")
mi.enqueue

But winamp just enqueues the file and doesnt parse the m3u. AW doesnt have support for IPC_CHANGECURRENTFILE yet, I am not sure exactly how this behaves, but it might let you load playlists, and play files with resetting the playlist. I will look at adding it in if so.


With regards to the single instantiation, AW is a singleton COM object. So multiple clients are actually using the same COM object as well as the same winamp.exe. I am working on a way to support both multiple and single instances by letting clients use GetObject with a window class name as a moniker. This wont affect anyone using AW+winamp in single instance mode, but it will allow people to obtain different instances of AW+Winamp if they needed to.

Last edited by shaneh; 12th February 2005 at 01:50.
shaneh is offline   Reply With Quote
Old 12th February 2005, 13:41   #211
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
<But winamp just enqueues the file and doesnt parse the m3u. AW doesnt have support for IPC_CHANGECURRENTFILE yet, I am not sure exactly how this behaves, but it might let you load playlists, and play files with resetting the playlist. I will look at adding it in if so.>

Hmm, this isn't what I was seeing.

If I do the following using VBSCRIPT:


set objtest=objWinamp.LoadItem("C:\Program Files\Winamp\songs.m3u")
objnew=objtest.enqueue

Then winamp loads the whole playlist, and not the m3u filename itself.


However, I ran into trouble when I tried to use a string variable for the m3u path:
filename="C:\Program Files\Winamp\songs.m3u"
set objtest=objWinamp.LoadItem(filename)

VBScript bombs on a type mismatch. I think this is because when you add parens around a method parameter, vbscript passes by reference, and the LoadItem method is expecting a string.

Initially thinking the method was expecting quotes, I tried the following:

set objtest=obj.Winamp.LoadItem(chr(34) & filename & chr(34))

Now this didn't bomb out, but loads the playlist with a single entry "songs", equal to the name of the m3u file. (This sounds like the behavior you were expecting with regards to the loaditem operation. But winamp is confused by this, and tries to play the "songs" mp3, which doesn't exist.

In other cases like this, I have been able to Omit the parens around the method parameter to force passing by value, but this also bombs out the LoadItem call "expected end of statement".
JohnKane is offline   Reply With Quote
Old 12th February 2005, 14:24   #212
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Ah yes, if its a valid m3u it will enqueue the whole playlist. I had a typo in my test and was loading the wrong file.

That behaviour is strange. It seems to be largely a problem with vbscript in general as I have seen some postings with other people having similar issues with COM-vbscript integration.

It is most certainly a ByVal/ByRef problem. LoadItem expects a BSTR*. This is unusual, as it is a [in] paramater only, every other [in] only paramater for the other functiones require just a BSTR. (no pointer*). I believe a BSTR is just a pointer to a lower level string with a ref count so its always passed by pointer in the low level implementation anyway. But for some reason I had made it a pointer to a BSTR, which shouldnt be needed unless it was acutally returning a modified BSTR.

I just took a look at the code and changed it to BSTR instead and it works ok. This will unfortuantly break anything that used it before, except script code.

What I could do is just add another method, LoadItem2 which behaves in this new and correct way. There is nothing really wrong with the other method, other than just not being script friendly.

Its not good form to change an interface like that once its published, but it really depends on how many people are using that method in compiled languages as to whether it will be ok or not.

Ive attached a copy of AW with the fixed method, plus it fixes the .position and .execvisplugin implementations.
Attached Files
File Type: zip aw.zip (85.3 KB, 833 views)
shaneh is offline   Reply With Quote
Old 12th February 2005, 15:26   #213
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
Wow, now thats what I call support! Thanks.

I hear you on the BSTR issue. I struggle with them any time I need work with Strings and COM objects. Everytime I think I have it down, I run into a similar issue.

Since passing the string as a variable was giving me a hard time, I bypassed it temporarily and just hardcoded a filename. This got my playlist loaded via the Com object.

However, if I try to execute a Play method across the COM interface, I bomb out with the following:

Winamp.exe
The instruction at "0x0407869d" referenced memory at "0x00000028". the memory could not be read.

I should note that in this case, I am calling ActiveWinamp via ASP(Server.createobject) on a windows server. This calls the com component as an automation object (no visible gui on the server).

I highlight this because if I instantiate ActiveWinamp with vbscript inside html (client side), the play method works and doesn't bomb out.
JohnKane is offline   Reply With Quote
Old 13th February 2005, 00:07   #214
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
It seems strange that there is no visible object, Im guessing windows server blocks that somehow. As winamp does not honour the /embedding or /automation switches, and AW does not attempt to look at them either. So winamp should just load as if it were started normally. Perhaps ASP runs under its own desktop station thing or something like that.

This sounds like a bug in winamp trying to deal with being launched in this way rather than AW. AW does nothing more than a sendmessage(play) to the window then returns on that method. Do the other methods work? It could be something that winamp attempts to do when playing that causes the problem. Did winampCOM work and play when launched like this?

Another possible reason is the events firing back causing the crash. If WinampCOM works ok, Id be pretty certain this would be the cause. Although winampcom does attempt to do some stuff with the /embedding and /automation switches, and uses multiple instances which could also be the source of the problem.

A workaround could be to simply start winamp beforehand. Because AW is a singleton com object, every 'createobject' etc just grabs the running instance. Which, if its run beforehand, will be a GUI instance running on the desktop. Thats assuming ASP is able to grab that instance through createobject, which it may not if its running on a different desktop station.
shaneh is offline   Reply With Quote
Old 13th February 2005, 14:31   #215
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
In ASP and w2k server, COM components launch without GUIs (automation servers). WinampCOM also works like this. WinampCOM's problem (for my application) is that it spawns multiple instances, which it can't actually service. So if a client makes a createobject call, and one already exists, a new instantiation is spawned, but the com object data gets scrambled. There is no way to correct this without manually killing the extra instantiations, and so thats a non-starter. ActiveWinamp doesn't do this, and I thought I had a working solution, until the crash.

All the other methods I have tried on the server with ActiveWinamp have worked, LoadItem, Playlist.Position, etc. As soon as I call Play, the winamp process crashes with the error I listed previously. When I call it locally as a client side activex object, its ok.

Having the Winamp GUI open ahead of time doesn't help. Even with ActiveWinamp being a singleton, a new winamp process is spawned, because ASP opens the COM component in a different user context. The instantiation of winamp from the gui is owned by the logged in user. But ASP processes run under different system account context.

Is there way another via ActiveWinamp to get a play command sent, like the general 'sendMSG' message? I think WinampCOM used the old message interface (40xxx style). That may be what you're doing internally anyway.

So close, and so far... and I doubt you have w2k server/IIS laying around to try instantiating in this fashion. Did you write the COM object in VC++? I could configure my server run off the vc++ debugger and try to see whats going on, but that would require the full project/source. (And of course that's a pretty big request to make.) If its really in winamp space, then I'm stuck. But winampCOM works, so that gives me some hope.
JohnKane is offline   Reply With Quote
Old 13th February 2005, 14:58   #216
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Im guessing it could be something to do with the events firing back. The code for Play is basically:

STDMETHODIMP CApplication::Play(void)
{
SendMessage(plugin.hwndParent,WM_COMMAND,40045,0);
return S_OK;
}

So I think the bug is related to what happens *after* the play is called. I doubt ASP has a sendmessage function anywhere, but if there is or something you can use, you could try sending this WM_COMMAND to winamp. But as I said, I think the events firing back is causing the problem.

AW was written in VC++ with ATL.

I have plans to relase the source to ActiveWinamp, so that is not much of a problem, however it really needs to be tidied up a bit first, there are some known bugs with the thread pooling for scripts, but that doesnt cause too many issues. Its also full of badly named variables and filenames etc etc, but its not too bad if youre just looking at the COM objects implementation. Its mainly the internal script hosting that gets a bit messy.

Check your PM
shaneh is offline   Reply With Quote
Old 17th February 2005, 06:25   #217
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
I guess you will be setting up a site on SourceForge then?? With full bugtracking and a team. (Will join you).
saivert is offline   Reply With Quote
Old 17th February 2005, 09:52   #218
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Yes, hopefully soon. Theres a bit of code tidying up and licensing decisions before then though. I wouldnt mind it being part of the offical winamp distribution. Winamp really should have some automation support to remain competitive.

As for WSH style script files (re your PM), you could work on that feature if you wanted, though the whole internal script hosting needs a bit of an overhaul. The thread pooling for the scripts is a bit broken, and the way the script objects are started is fairly inefficent.

I think better support for starting and stopping running scripts, multiple instance support, ability to dynamically add and remove menu items and hot keys, more and better events, better ML methods etc also need to be worked on. Plus internal objects need to be imporved a little, to reduce the need for all the fixed sized buffers etc.

So theres plenty to be 'fixed' before adding new features which probably wouldnt be used by most people. Remeber that you can run scripts external to winamp if you want complicated WSH object support, the AW object is just accessed out of process rather than in process.
shaneh is offline   Reply With Quote
Old 17th February 2005, 12:56   #219
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
dynamic add and removal of menu items can be made possible by implementing WSF type file support. Use special XML tags to define the menu items and use methods on a IMenuItem interface to show/hide.

WSF files would also remove the need to have special filenames for scripts ("playlist_", "sendto_" and "startup_" prefixes) because this will be specified using tags in the WSF file. And you can specify the script language using the SCRIPT tag's language attribute.

You could possibly add more special tags to define more complicated behaviour.
saivert is offline   Reply With Quote
Old 19th February 2005, 18:05   #220
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
Shane,


FYI: after a lot of testing, it looks like both WinampCOM and ActiveWinamp objects behave the same way with Winamp 5.0. Executing the Play method from ASP on w2k server causes an exception in winamp (the classic 'memory could not be read' (Songs do start playing for a few seconds before the crash occurs, I was missing this subtlety).

I tried a good deal of experimenting to get around it, but no dice. I'd love the write a Winamp bug against it, but I would probably be flogged since it shows up in plugin space. Not to mention I don't expect there are too many people running this under ASP on a server.

WinampCOM didn't have this issue in Winamp 2.78 or Winamp 3. Of course, these versions won't work with ActiveWA, so thats out too. Since both WinampCOM and ActiveWinamp objects are simply using a SendMessage Play call, I doubt its related to anything in the third party code. Most likely there is some issue with the call in '-embedding' mode, since this is how all COM objects are instantiated in ASP.

Oh, one other thing: I can't make "SendMsg" calls from VBscript in ASP either. I think the wparam, lparam types can't get across the COM interface. VBScript throws an "unsupported automation type" error. Maybe you could consider passing the args as longs, since these seem to pass properly within the variant constraints of VBscript. I guess this is another case where you may need an alaternate version of the method.
JohnKane is offline   Reply With Quote
Old 20th February 2005, 00:48   #221
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
WinampCOM strips the -embedding argument AFAIK, so I suspect Winamp just cant handle running in the 'headless' state, or with those permissions or whatever ASP does to running processes. There might be something you can do with ASP to let the process run as a standard process.

The SendMsg call was done like that because VBScript doesnt support unsigned longs, only signed longs. It may be possible to just use a long, but at the time of writing that was the solution I researched and seemed to be what should be used.
shaneh is offline   Reply With Quote
Old 20th February 2005, 06:40   #222
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Also, you might like to check with this other scripting plugin:
http://www.pretentiousname.com/gen_scripting/

to see if you have any luck.
shaneh is offline   Reply With Quote
Old 21st February 2005, 01:23   #223
JohnKane
Junior Member
 
Join Date: Feb 2005
Posts: 6
Shane,

I have had some success with getting this to work, but I had to edit the identity that the process launches under. This forces the gui to appear, and the problem went away for now. This requires having an account logged on to the server at all times, but at least it's not crashing.

I still go back to the fact that winampcom worked under winamp 2.78, so I know its not entirely ASP's fault that it doesnt work in 5.0. But I have something to work with now.

VBScript definitely doesn't like the params in SendMsg/PostMsg calls. I'll have to take a look and see if there's another alternative.


Thanks,

John
JohnKane is offline   Reply With Quote
Old 21st February 2005, 01:38   #224
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
It could be something that winamp is doing in verison 5 which is causing ASP to be "at fault" if you know what I mean. For example, modern skins might be causing v5 to request some graphics primitive that isnt allowed when running under ASP (just an example). Winamp was clearly not intended to be run in this way

Ill look further into the sendmsg stuff soon. I do recall it working for me with vbscript, though perhaps I changed it, as I just checked and it doesnt seem to be functioning too well.
shaneh is offline   Reply With Quote
Old 24th February 2005, 04:44   #225
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Please see:
http://sourceforge.net/projects/activewinamp/

For source and development discussion. Pay careful attention to release notes, news items, trackers and forum posts before diving in.
shaneh is offline   Reply With Quote
Old 24th February 2005, 11:52   #226
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
I want a script that removes all songs just played from the playlist. When I run the script below, Winamp crashes. I don't understand why. Anyone? Tx in advance

Sub Application_ChangedTrack
If playlist.position > 1 Then
playlist.deleteindex(1)
End if
End Sub
CaAl is offline   Reply With Quote
Old 28th February 2005, 08:20   #227
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
How about writing a NT service application that runs in the background and receives commands from an ActiveX Scripting Object (ASP) through named pipes or something. Then It could hook into the Windows Station running Winamp and send messages to it. Just an Idea.. I would certainly use a lot of time writing the myself.
saivert is offline   Reply With Quote
Old 14th March 2005, 03:47   #228
frozdsolid
Junior Member
 
frozdsolid's Avatar
 
Join Date: Mar 2005
Posts: 3
Does your scripting interface have to start winamp?

I was playing a little with your scripting interface in C# and noticed that immediatly upon instantiating the COM object, winamp launches. I'm sure this behavior is probably relevant to the nature of COM. I don't know a whole lot about it so I can't be sure (I wish I did!).

To briefly explain why this behavior is relevant, I'm writing a small C# app that updates my AOL Instant Messenger (AIM) profile with the song I'm currently listening to. It relies on a dll that gets loaded into aim (my friend wrote it) that responds to a message that updates the profile. Currently I've interfaced with iTunes via COM, and everything is good. Now I'm adding winamp support.

The behavior of the app is such that if itunes isn't loaded, it just does nothing, and waits until iTunes is launched. Once it does, it starts responding to track change events and updating my AIM profile. If iTunes quits, the cycle repeats. Is this something that your interface can accomplish, or should I maybe write my own simpler winamp plugin that just sends out a windows message to my app on track change events?
frozdsolid is offline   Reply With Quote
Old 14th March 2005, 12:40   #229
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
You can use "GetObject" instead of "CreateObject" to try obtain a running instance. It will return an error if its not running. I am not sure how to do this in C#, but Im quite sure there would be a way, its standard COM stuff. Otherwise you can just test with "FindWindow" or some other technique to see if Winamp is running.

There is no way to "wait" until winamp is launched. I dont know how you are doing it for iTunes, I was not aware iTunes broadcast a system message that it was starting. (that is what would be required to achieve that AFAIK).
shaneh is offline   Reply With Quote
Old 14th March 2005, 13:16   #230
frozdsolid
Junior Member
 
frozdsolid's Avatar
 
Join Date: Mar 2005
Posts: 3
I take advantage of this weird behavior, in the iTunes COM object. If I instantiate the object, iTunes doesn't appear to open, but once it does open, the events start working fine. When it quits the object becomes useless, so I catch the on quit event and reinstantiate the object then.

So I guess I'll just write my own winamp plugin that would broadcast when it loads, then I can just use yours once it does....
frozdsolid is offline   Reply With Quote
Old 15th March 2005, 00:11   #231
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
I would imagine iTunes is actually starting, have you looked in the process list? It is probably starting, but just not showing any GUI.
I think ActiveWinamp currently doesnt have a 'quit' event, so your plugin may need to broadcast that event too, unless you want to edit the source to AW to add it in. I wil add it in myself eventually.
shaneh is offline   Reply With Quote
Old 15th March 2005, 21:58   #232
frozdsolid
Junior Member
 
frozdsolid's Avatar
 
Join Date: Mar 2005
Posts: 3
Yea, I don't see iTunes showing up in the process list but I have a feeling that it's somehow starting because iTunes loads a lot faster once i instantiate the object.

Once I started writing my plugin I realized that I could just add a bit more code to send out the song title (maybe using a memory mapped file) to my profile updating program, and not have to deal with some of the strange and seemingly unpredictable COM behavior (again, I'm not a COM expert, so this could be my fault -- COM just seems slow sometimes as it tends to hang the client and server if there are any sort of problems)

But your advice and activewinamp source code have been a HUGE help. I don't know how I would've figured out the proper way to subclass the wndproc and catch the necessary events without your source.
Thanks!
frozdsolid is offline   Reply With Quote
Old 16th March 2005, 09:39   #233
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Quote:
Originally posted by CaAl
I want a script that removes all songs just played from the playlist. When I run the script below, Winamp crashes. I don't understand why. Anyone? Tx in advance

Sub Application_ChangedTrack
If playlist.position > 1 Then
playlist.deleteindex(1)
End if
End Sub
Because there hasn't been an answer yet, and I am still waiting for one, here's a repost.

So, what I want with my script: each time the playlist advances one song, the first song in the playlist (which thus has already been played), should be removed. The script I wrote was:
Sub Application_ChangedTrack
If playlist.position > 1 Then
playlist.deleteindex(1)
End if
End Sub

But, this doesn't work. As soon as the track changes, winamp crashes pretty nasty... Please, can anyone help me out here?
CaAl is offline   Reply With Quote
Old 16th March 2005, 09:53   #234
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
Hmm, that script seems to work fine for me, thoughit does crash when there is only 2 items left in the playlist. Ive fixed it up a bit, and doesnt seem to anymore. Grab the lateswt .dll from the CVS.

http://activewinamp.sourceforge.net
shaneh is offline   Reply With Quote
Old 16th March 2005, 12:01   #235
CaAl
Junior Member
 
Join Date: Apr 2004
Location: NL
Posts: 23
Quote:
Originally posted by shaneh
Hmm, that script seems to work fine for me, thoughit does crash when there is only 2 items left in the playlist. Ive fixed it up a bit, and doesnt seem to anymore. Grab the lateswt .dll from the CVS.

http://activewinamp.sourceforge.net
thanks, now it works (and, yes, the script needed some additional tweaking and finetuning )
CaAl is offline   Reply With Quote
Old 18th March 2005, 16:16   #236
dhorrocks
Junior Member
 
Join Date: Mar 2005
Posts: 1
Hi

I've been making a program in c# using your brilliant app here.. I've used the dll and have now hit a problem.

Quote:
trackArray = winamp.MediaLibrary.RunQueryArray("artist HAS blink");
That works fine.. the problem is how would I count how many items it's returned and use a loop on that? And how from that would I access each songs tracks name. I've got it working for artists looping. But this just seems impossible to get working

Any help would be appreciated.
dhorrocks is offline   Reply With Quote
Old 18th March 2005, 23:35   #237
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
You just need to use the length of the array. ie:

Array trackArray = (Array)winamp.MediaLibrary.RunQueryArray("artist HAS Powderfinger");
MessageBox.Show(Convert.ToString(trackArray.Length));

Or you could use the newer version of AW in the CVS and use the "RunQuery" method which returns an object, which has a Count and enumerator etc. This is a bit faster in the short term than runqueryarray, especially when used out of process, but can be slower in the long term. ie, the MediaItem objects are created on demand, rather than creating and returning the entire array. But if you intend to inspect *every* item that is returned, runqueryarray may be the better alternative.

I may make some changes to the RunQueryArray method, as it should really be casting to "Array" automatically. I kind of know where to start with this, but we will see. AW 2.0 is starting to shape up nicely, and Im hoping it will hit the streets soon.
shaneh is offline   Reply With Quote
Old 28th March 2005, 14:02   #238
antu^jamban
Junior Member
 
Join Date: Mar 2005
Posts: 3
This is a great plugin. I already use it for my widget LINK. Thanks for creating it.

I'm having a problem. I tried using ATFString to get the sample rate (%srate%) but it returns 0. Is there anyway I can make it to work? Another thing I notice, the plugin didnt support VBR. Any chances we're going to have this?

Thanks in advanced. BTW, I'm coding in VB
antu^jamban is offline   Reply With Quote
Old 29th March 2005, 02:18   #239
shaneh
Major Dude
 
Join Date: Jan 2004
Location: Brisbane, Australia
Posts: 1,193
This is because AW gets the sample rate and bit rate using an API which is based on the currently playing file. ie:

#define IPC_GETINFO 126
/* (requires Winamp 2.05+)
** int inf=SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETINFO);
** IPC_GETINFO returns info about the current playing song. The value
** it returns depends on the value of 'mode'.
** Mode Meaning
** ------------------
** 0 Samplerate (i.e. 44100)
** 1 Bitrate (i.e. 128)
** 2 Channels (i.e. 2)
** 3 (5+) Video LOWORD=w HIWORD=h
** 4 (5+) > 65536, string (video description)

Although bitrate is retrieved from the ML if available. I dont think Winamp provides an API to get the sample rate from anything but the currently playing song, but I could be wrong. You can see the source of ActiveWinamp at http://sourceforge.net/projects/activewinamp/ to see the exact implementation details. If there are particular changes required to better support such meta data feel free to make them.

You can use the following to make the above call:

mode = 0
x = SendMsg(1024, mode, 126)
msgbox x
shaneh is offline   Reply With Quote
Old 29th March 2005, 02:36   #240
saivert
Banned
 
saivert's Avatar
 
Join Date: Jan 2001
Location: Norway
Posts: 927
Doesn't the ML database keep bitrate, samplerate and channel info about each song? I really think so or else it would be slow to browse through ones ML if one had over 2000 songs in a list.
saivert 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