Mzscript and a winamp play/pause button? Thread last updated on 2004-06-05 19:13:12

Posted by member 57005 on 2004-06-05 08:28:29

I have some trouble with getting a rather simple mzscript to work. I'm more or less a newbie in scripting and this is the first time I really need to use it.

Anyway, I use the Gandharva module to control winamp. When I press the play button and a song starts playing I want the play button to disappear and a pause button should take it's place. This would do the trick:

If winamp playing
*Shortcut "" 36 -55 amp_pause1.png amp_pause2.png amp_pause3.png #200H !GandharvaCmdPause
Else
*Shortcut "" 36 -55 amp_play1.png amp_play2.png amp_play3.png #200H !GandharvaCmdPlay
EndIf


I just need a script to control the "winamp playing" var. I know how to create a script that changes the button when I change the var by hand, but I'm having trouble getting it to work just by pressing this play button. Could anyone help me with this?

BTW, I cannot use a "!shortcutgrouphide" or a "!shortcutgroupshow" bang since the winamp controls are already on an extended bar which uses these commands to show or hide the entire bar (take a look at "http://www.litestep.net/upload/profiles/LunaStepWMP9_57005-684.png").

Posted by member 37809 on 2004-06-05 09:37:54 link

Your approach and constraints make it difficult IMO. Step.rc if/then/elses are static in nature. The way to go is to use xlabel (or xlabellight) and mzscript.

Create a hidden label whose text is "[winampStatus]"

Set its update interval accordingly. Something like 100ms or less would be best for user feedback. That is, whenever winamp's playback status changes, the maximum delay before the label updates its text is 100ms (but on average it should be 50ms).

Have the label's onTextChange event call a custom bang. In this custom bang !labelmzscriptvarcopy to an mzscript variable and then based on that, show the appropriate shortcut through bangs. You will have to isolate these shortcuts by giving them unique groups IDs.

I don't know how omnipotent xlabel has gotten at the time of this writing but I wouldn't be surprised if you could use the same xlabel as a single shortcut itself. That is, try offsetting the text so that it's not shown. Then instead of having to toggle the visibility of shortcuts, you could use !LabelRefresh to update its images on-the-fly.

The elegance in this solution is that you can control winamp through whatever means and litestep will still be aware of winamp's playback status, automatically updating the image and semantic of the button you made.

Posted by member 57005 on 2004-06-05 09:59:29 link

Thanks for the quick answer! I will see what I can do, but probably I will have some trouble since these shortcuts are on an extended bar that can be shown or hidden. This is a problem as hide/show shortcuts will have to call just one of the play and pause buttons and that surely screws everything over. :P I'll look at the new versions of xlabel as I have xlabellight at the moment which is way older...

Thanks again, you might have made my day. :)

Posted by member 7223 on 2004-06-05 10:14:26 link

@tnl: since xLabel-3.0 you should use !LabelInfoExport (mzscriptvar) "[text escape sequence]"

Posted by member 37809 on 2004-06-05 10:15:54 link

I use xlabellight-2.8.3 myself.

Actually I'm using a longer update interval since I primarily use my shortcut (actually a skinbox) to !amp_playpause;
as an optimization have your shortcut !labelupdate your status label and the image change should happen faster.

My scripts for this look somewhat horrendous since I'm using skinbox, so I loathe editing an example for this.

@Smurth: Perhaps I'll look into rehauling to xLabel should development/updates on it ever slow down :P

I simply don't have the time/patience to rescript everything whenever modules/updates provide conveniences.

See even my guide above is outdated in terms of bangs :)

Posted by member 12025 on 2004-06-05 19:13:12 link

You can do some pretty simple scripting for this (look in xLabel's docs).
Have a label with the status off-screen, say put it's Y value a bit beyond $ResultionY$.
I couldn't get the ascape sequence alone to do the work right, but exporting the text of an actual label still works fine (haven't tried it in 3.0.5, though, just 3.0).