Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: How to Control Winamp via X-10 commands, start music automatically, etc.  (Read 22040 times)

billallyn

  • Newbie
  • Helpful Post Rating: 5
  • Posts: 7
    • BillAllyn.com

Ok... This took me awhile. I found a workaround to have BXVC play mp3s or Winamp playlists, and access commands within Winamp. And it's free! And, I can now start winamp and access winamp commands via my RCA remote (RC1310A), as another benefit. I heard you guys talking about this subject and I knew it must be possible somehow... So...

There is a free command line interface for Winamp called, not too surprisingly, CLAmp (http://www.softpedia.com/get/Multimedia/Audio/Other-AUDIO-Tools/CLAMP.shtml) [it's a small program, 116kb--I put it in my windows directory so it would be in my "path"--I think?].

Now when I say "Music, Maestro!", BXVC sends a command to AHP, which executes a macro, which executes a very simple batch file I wrote, which starts winamp (via the command line interface), turns on random play, clears the current playlist, opens a playlist of my choosing, selects a random song, plays it (and then the rest of the songs, randomly, of course), and then minimizes winamp. Man, I'm glad my computer now does this for me--I'm out of breath just typing it!

And when I say, "Next song, Hal" ("Hal" is the name of my computer in BXVC, named after Hal 9000 in 2001: A Space Odyssey), BXVC sends a command to AHP, which executes a macro, which executes my "next.bat" batch file, which tells CLAmp to tell Winamp to start the next (random, or not...) song. Takes about 2-3 seconds on my Pentium III 600. Of course, if you have your music up loud, you can pretty much forget issuing ANY commands at that point.  Where is Bill's Mind Commander? LMAO!!! She's in the kitchen, cooking Bill breakfast...

Yes, it's a bit of a convoluted way of doing things, since you must program BXVC, an AHP macro, and create a batch file (well, three or four, maybe). But each part is really very quick, easy, and painless.

I did have a couple problems, though, but they were solved fairly easily.

One problem was that, while Winamp would open the playlist and play the songs randomly, the FIRST song would always be the first song in the playlist (always the same song), and I didn't want that! No matter what I did, it would not play a random first song!!! So, I created a 1 second silent mp3, and used that as the first song in my playlist. Viola! First song is now always random.

Another problem was that in the batch file I couldn't get it to clear the playlist first, and then load a new list (which is odd because both commands worked fine by themselves...). So I actually made three batch files, and used an AHP macro to run them in succession (without adding any delay). Works perfectly now. It looked something like this:

001.bat contains:
@ECHO OFF
CLAMP /START

002.bat contains:
@ECHO OFF
CLAMP /PLCLEAR

003.bat contains:
@ECHO OFF
clamp /load "d:\bands\database\orig_mp3s\bill01.m3u" /random=1 /play /minimize

next.bat contains:
@ECHO OFF
clamp /next

Available Winamp commands via CLAmp:

Usage

CLAMP {Options}

It is (sometimes) possible to perform more than one task at a time by adding multiple options on the same line.
Each option must be preceeded by /

Upon success, program will quit with an exit code of 0.
Upon failure, exit code will be set to 1.


Program Control
START ............ Start Winamp
QUIT ............ Exit Winamp

Note : any following option will automatically start winamp if necessary - No need to use /START as first option.

General Control
PLAY ............ Play (current file) - Quits Stopped or Pause mode
STOP ............ Stop playing
STOPFADE ............ Stop playing with fadout
STOPAFTER ............ Stop playing after current track (returns now, stops later)
PAUSE ............ Toggle pause mode
PLAYPAUSE ............ Same as above
NEXT ............ Play next song
PREV ............ Play previous song
FWD ............ Forward 5 seconds
FORWARD ............ Same as above
REW ............ Rewind 5 seconds
REWIND ............ Same as above
RESTART ............ Restart current track from beginning (not working with Winamp 2)


Winamp Modes
REPEAT ............ Toggle Repeat mode
SWREPEAT ............ Same as above
REPEAT ON ............ Set Repeat mode ON
REPEAT=1 ............ Same as above
REPEAT OFF ............ Set Repeat mode OFF
REPEAT=0 ............ Same as above
RANDOM ............ Toggle Random mode
RANDOM ON ............ Set Random mode ON
RANDOM=1 ............ Same as above
RANDOM OFF ............ Set Random mode OFF
RANDOM=0 ............ Same as above


PlayList Control
PLADD ............ Add file(s) to end of playlist (like drag-n-drop)
LOAD ............ Same as above
PLCLEAR ............ Clear Playlist
CLEAR ............ Same as above
PL ............ Show/Hide Winamp Playlist window
PLWIN ............ Same as above
PLPOS ............ Query Playlist position
PLFIRST ............ Play first item of playlist
PLLAST ............ Play last item of playlist


Volume Control
VOLUP ............ Volume up
VOLDN ............ Volume down
VOLSET ............ Volume set (scale 0-255)
VOLMAX ............ Volume max
VOLMIN ............ Volume min (mute)


Infos
POS ............ Query current position in file and track length
POSITION ............ Query current position in file only
STATE ............ Query current state (PLAYING;PAUSED;STOPPED;NOT RUNNING)
STATUS ............ Synonym for STATE
TITLE ............ Query current track title
VER ............ Query Winamp version


Winamp Interactive Windows
ABOUT ............ Display Winamp About window
PREFS ............ Display Winamp Preferences window
OPEN ............ Display Winamp Open File window


Equalizer Control
EQWIN ............ Toggle Eq window (Works with Classic skins only)
EQINFO ............ Query Eq parameters (10 bands, Preamp, Status, Autoload)
EQSET ............ Set Eq parameters (Same format as EQINFO)
EQSTATUS ............ Toggle Eq status (ON / OFF)
EQSTATUS ON ............ Set Eq status ON
EQSTATUS OFF ............ Set Eq status OFF


Winamp Display
ONTOP ............ Toggle Always On Top option
MAINWIN ............ Toggle Main Window (Show / Hide)
MINIMIZE ............ Minimize Winamp


Misc
CDPLAY ............ Play CD


Examples


CLAMP /PLAY
CLAMP /PLCLEAR /PLADD "MySong1.mp3" /PLADD "MySong2.mp3" /PLAY


----------------

If anyone needs more help, let me know. I could give more detailed instructions if there is a need, and if I know what people are having problems with.

--Bill Allyn
Logged
My family moved alot when I was young, but I always found them.

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!

Good find and post! ;)
You don't need to send a command to AHP, BVC should be able to execute your command line winamp program on its own!(although I've yet to play with this feature)
Bill could probably elaborate on this! ;) :D
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

-Bill- (of wgjohns.com)

  • Advanced Member
  • Hero Member
  • ******
  • Helpful Post Rating: 81
  • Posts: 1340
  • He's just this guy. You know?
    • wgjohns.com

Good find and post! ;)
You don't need to send a command to AHP, BVC should be able to execute your command line winamp program on its own!(although I've yet to play with this feature)
Bill could probably elaborate on this! ;) :D


The present incarnations of BXVC and BVC do not execute programs or command line commands.  So the work-around at present is to have BVC send an X10 signal which is picked up by an AHP MACRO which executes the command line command.
Logged
-Bill- (of wgjohns.com)
bill@wgjohns.com

In the real world, the only constant is change.

When I'm online you can find me in the Home Automation Chat Room!

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!

[The present incarnations of BXVC and BVC do not execute programs or command line commands.  So the work-around at present is to have BVC send an X10 signal which is picked up by an AHP MACRO which executes the command line command.
I guess there's another feature to add Bill  ;) Not to difficult with BVC using VB 2005 Express! ;)
I thought I seen the option? ??? ..............Ah I see it is only for commands you (Bill) have added! :-[
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

kenrad

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 198

Ive been fighting with this WinApm and Clamp stuff all night with no success.  Does any one know how to access playlists from any of the following programs Windows media player, winamp, or Itunes and to run them from a macro from AHp

Thanks
KenRad B:(
Logged

hawk1

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 625
Logged
koopr@sstelco.com, I don't know what I'm doin but I'm havin fun doin it!

ITguy

  • Sr. Member
  • ****
  • Helpful Post Rating: 8
  • Posts: 105

This might do what you want.  Just have your HA program trigger the AutoHotKey script (compiled into an exe program) when it detects your X10 device "on" command.  This uses Clamp, so you should be able to do the same with any command that's supported by Clamp, though I haven't tried it.  This script starts WinAmp, telling it to play the playlist named "All.m3u" that's located in folder C:\Music, then minimize the Winamp screen.
Code: [Select]
;
; Script Function:
;       Start WinAmp

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


run clamp.exe /START /PLAY C:\Music\All.m3u /MINIMIZE

As another example of what's possible, the script below is a "go to sleep" script that starts Winamp, pauses for 35 minutes, then tells Winamp to stop playing when it completes playing the current track.  It also uses NIRCMD to force WinAmp to end.  I tried using the Clamp commands for that, but it wasn't reliable.  NIRCMD kills it without fail.  If you use this script, you should run it in a "nowait" mode so it doesn't tie up your macro process queue.  I'm not sure how to do this in AHP, since I use iHouse for all my HA control, but maybe someone else can chime in.
Code: [Select]
; Script Function:
;
;       Start WinAmp
;       Pause 35 minutes
;       Stop winamp at end of current track

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

run clamp.exe /START /PLAY C:\Music\All.m3u
Sleep, 500
runwait clamp.exe /MINIMIZE
Sleep, 2100000 ; pause 35 minutes
runwait clamp.exe /QUITAFTER
runwait nircmd killprocess winamp.exe

Hope that gives you some ideas!

ITguy
Logged

billallyn

  • Newbie
  • Helpful Post Rating: 5
  • Posts: 7
    • BillAllyn.com

Ive been fighting with this WinApm and Clamp stuff all night with no success.  Does any one know how to access playlists from any of the following programs Windows media player, winamp, or Itunes and to run them from a macro from AHp

Hi Kenrad,
I am the original poster. Since then, I've replaced my computer, and only just now decided to get all my home automation stuff going again. I had long since forgotten exactly how I made winamp work, and was just hoping beyond hope that my post was still here, so I could follow my own instructions!!!  And here it is! Silly world. So, anyway, I'm having to redo this on my own system, so we can just work together on this. It really does work! It will amaze your friends (for nearly 3 seconds, until the next bright shiny object comes along...)

First, get the newest version of CLAmp.exe as well as the extensive list of potential commands at: http://membres.multimania.fr/clamp/

Don't double click on it, it won't install or do ANYTHING. You will be accessing it via batch files. Put it in your "windows" directory, so it will be in the "path", so that batch files will be able to access the clamp.exe program, and control Winamp.

Then create your batch files (001.bat, 002.bat, etc, or whatever you want to name them). A batch file is just a text file that is named with the .bat extension, and contains some kind of computer code stuff.

 001.bat contains:

@ECHO OFF
CLAMP /START



002.bat contains:

@ECHO OFF
CLAMP /PLCLEAR



003.bat contains:

@ECHO OFF
clamp /load "d:\bands\database\orig_mp3s\bill01.m3u" /random=1 /play /minimize



next.bat contains:

@ECHO OFF
clamp /next



Just open a new text document, copy in one of the commands above, and save it as "001.bat" or "function.bat" or whatever.  Do the same for the other essential commands (for instance, the four above. for me, that's really all I needed). You can create other commands as you see fit, and it will get easier, once you've gotten it to work once.

Now test the batch files by double-clicking on them. Does it do what it's supposed to when you double click on it??  Does Winamp come up? Does the play list load? Good! You now have command line control of Winamp. We're halfway there.

Now all we have to do is create macros within AHP to run those .bat files, and then initiate those macros with Bill's Voice Commander (Actually, I'm still using an old version of BXVC, which I like better than the shareware BVC, because it doesn't time out, and I can edit the code to make the program better [for me, anyway...], even if I don't know exactly what the hell I'm doing, which I often don't).  BVC is probably slightly easier to use, in the long run, and well worth the $30 donation. I'll be getting it soon myself.

Also, if I'm not mistaken, you need the AHP "Smart Macros" plugin installed, which I haven't reinstalled yet, so....  the rest will come later tonight as I redo this. Did you get the .bat files to work, and start doing things in Winamp?  Any questions so far?

Bill Allyn 



« Last Edit: May 24, 2011, 10:52:09 PM by billallyn »
Logged
My family moved alot when I was young, but I always found them.

Deemar

  • Sr. Member
  • ****
  • Helpful Post Rating: 2
  • Posts: 116

Seeing all the crazy workarounds you guys are doing for such a simple piece of functionality makes me want to put together a full blown X10 software product with everything built in. I wish I had more time to focus on it.
Logged

kenrad

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 198

A full blown program would be awesome.  Im gonna start working on the batch files and clamp tonite an d we will see how it goes.

KenRad >!   Bill thank you for your help I am a computer idiot and don't have a clue i appreciate all of your input. #:)
Logged

kenrad

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 198

cant get bat files to recognize clamp it wont even open winamp.  Im confused when I run the bat file a window pops up quick and then closes but noting in win amp starts.  anyone have any ideas what I'm doing wrong.  I put clamp in the same folder with winamp.???????????????? B:(

Thanks KenRad
Logged

billallyn

  • Newbie
  • Helpful Post Rating: 5
  • Posts: 7
    • BillAllyn.com

"I put clamp in the same folder with winamp."

That's what you're doing wrong. Put it in the "windows" directory and forget about it.  It doesn't matter where you put your .bat files (as long as clamp.exe is in the windows folder, your .bat files will find it just fine).

I'm having fun. I just programmed a credit card remote with these functions:
1. Start Winamp to random song   2. Next song
3. Pause     4. Play
5. Back 15 seconds   6. Forward 10 seconds
7. Volume up 10%.   8. Volume down 10%.

Cool, eh? Now I can change my tunes while I'm chilling on the patio. And this works all the time, when voice commands do not, because voice commands get garbled by loud, or even soft, music (although you might get away with more if you use a head set microphone. I use my webcam's microphone, and can issue commands from anywhere in the room, IF the music is not going. So I can start winamp by voice from anywhere in the room, but once it's going, bye-bye voice control.

I just figured out a better way, with the new version of clamp, to start a playlist to a random song, and it only takes one .bat file and you no longer need the 1 second mp3!! This adds another benefit: If Winamp is not going, it will start it playing a random song of your playlist, but if winamp is already started, it will just select another random song and play it - two buttons in one, sort of.

--------------
@ECHO OFF
clamp /PLCLEAR /load "D:\Bill's Documents\Mp3s\_01.m3u" /PLSET RANDOM /play
--------------

IMPORTANT: The part in parenthesis MUST point to your actual playlist (this is REALLY important).  I happen to keep "My Documents" on my D: drive, so if you just copied this code exactly, it almost certainly would not work, unless you just happened to keep your playlist in the exact same location as mine and named it the exact same thing, which isn't very likely.

So, if your playlist is named "kenrad.m3u" and is in your "My Documents" folder, then it might something like this:

@ECHO OFF
clamp /PLCLEAR /load "C:\My Documents\kenrad.m3u" /PLSET RANDOM /play


You can find out the actual path to your playlist, by going to the file in windows explorer, clicking once on the file to select it, then look up in the address bar, that is the location that you need to use, just copy and paste it, and then add the kenrad.m3u part (or whatever your playlist's filename is), because it probably was not part of the address. That should work.

If you put clamp.exe in the "windows" directory and use the correct, actual path to your playlist file, it will almost certainly work just fine.

I'll soon post the other seven .bat files to create a credit card Winamp remote control.


Logged
My family moved alot when I was young, but I always found them.

billallyn

  • Newbie
  • Helpful Post Rating: 5
  • Posts: 7
    • BillAllyn.com

Deemar,

Do you write software for X10, the company--or for a third party, or just for "fun"?

What program/language would you use to write the winamp control software?



--Bill

Logged
My family moved alot when I was young, but I always found them.

billallyn

  • Newbie
  • Helpful Post Rating: 5
  • Posts: 7
    • BillAllyn.com

Kenrad,
You'll want to check out this tutorial to create a Winamp Remote Control from an X10 Credit Card Controller.

http://forums.x10.com/index.php?topic=23627.0

Of course, someone has already created a program to do this for Windows Media Player, here: http://forums.x10.com/index.php?topic=16511.0

I found this out after writing this tutorial.... but I don't really like Windows Media Player, anyway, so...

--Bill Allyn


Logged
My family moved alot when I was young, but I always found them.

Deemar

  • Sr. Member
  • ****
  • Helpful Post Rating: 2
  • Posts: 116

cant get bat files to recognize clamp it wont even open winamp.  Im confused when I run the bat file a window pops up quick and then closes but noting in win amp starts.  anyone have any ideas what I'm doing wrong.  I put clamp in the same folder with winamp.???????????????? B:(

Thanks KenRad

Either put the Clamp file in the Windows directory or add the Winamp directory to the environment path variables in Windows.
If you ever want to see what the quick window popup says, open a command line window and run it by calling it from there. Whatever text gets displayed as an error will stay on the screen for you to see.
Logged
Pages: [1] 2
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.