Winamp::Control - control winamp (over the network)
use Winamp::Control; use IO::Extended qw(printfln); my $winamp = Winamp::Control->new( host => $opts{host}, port => $opts{port} ); if( my $ver = $winamp->getversion ) { printfln 'Connected to Winamp (Ver: %s)', $ver; printfln 'Currently playing: %s ', $winamp->getcurrenttitle() if $winamp->isplaying(); println "Current playlist:\n\t", join "\n\t", $winamp->getplaylisttitle(); }
Winamp::Control is a perl module for controlling Winamp (www.winamp.com) over a network or local. It requires the httpQ winamp-plugin written by Kosta Arvanitis (see prerequisites) installed on the computer playing the music (It is called "server" and will receive the commands). Perl clients doesn't need it, because the clients are communicating via http (and they are not restricted to any operating-system).
127.0.0.1
The host address where the httpQ plugin and Winamp is running.
Winamp
4800
The httpQ plugin port.
A plain text password to httpQ (required if set via the httpQ preferences).
[Note] The parameters have also instance methods counterparts. So you may call them after construction like:
$winamp->host( $host ); $winamp->port( $port ); $winamp->passwd( $passwd );
action: Like clicking on it. argument: none. return: 1 on success, 0 otherwise. example: $winamp-><command>
action: Get the current version of your winamp player. argument: none. return: Version of winamp, or 0 on error. example: $winamp->getversion
action: Clears the contents of the play list. argument: none. return: 1 on success, 0 otherwise. example: $winamp->delete
action: Get the playing status of winamp player. argument: none. return: 1 = playing, 0 = not playing, 3 = paused example: $winamp->isplaying
action: Returns the position in milliseconds of the current song, or the song length, in seconds. argument: 0 Position (in ms) of current song, 1 Length (in sec) of current song return: -1 if not playing, 0 on error. example: $winamp->getoutputtime( a => 1 );
action: Sets the position in milliseconds of the current song (approximately) to 'argument'. argument: Position in milliseconds to jump to. return: 1 on success,0 otherwise example: $winamp->jumptotime( a => 1000 ); #jump to 1 second
action: Sets the playlsit position to 'argument'. argument: Position to set play list to. return: 1 on success,0 otherwise example: $winamp->setplaylistpos( a => 1 ); #set play list to position 1
action: get the length of the current playlist, in tracks. argument: none. return: The current track number or 0 on error. example: $winamp->getlistlength
action: returns the title of the playlist entry at index 'argument'. note: if no argument is specified, returns a list of all the titles in the playlist seperated by '<br>'. argument: index in the list from which to retrieve title. note: the list is zero indexed so track 1 is 0. return: Title of track or 0 on error. example: $winamp->getplaylisttitle( a => 1 ); #get title at list index 1 or $winamp->getplaylisttitle; #get a list of titles
action: Returns the file name of the playlist entry at index 'argument'. note: If no argument is specified, returns a list of all the file names in the playlist seperated by '<br>'. argument: Index in the list from which to retrieve title. note: The list is zero indexed so track 1 is 0. return: Filename of track or 0 on error. example: $winamp->getplaylistfile( a => 1 ); #get file name at list index 1 or $winamp->getplaylistfile; #get a list of file names
action: Gets the current index of the play list. note: The list is zero indexed so track 1 is 0. argument: none. return: List position or 0 on error. example: $winamp->getlistpos;
action: Change the working direcotry to argument. argument: The path to the new current working directory. return: 1 on success, 0 otherwise. example: $winamp->chdir( a => 'c:\mp3' );
action: Appends a file to the playlist.The file must be in the current working directory or pass in the directory with the filename as the argument. argument: The file name to append to the playlist. return: 1 on success, 0 otherwise. example: $winamp->playfile( a => 'music.mp3' ); $winamp->playfile( a => 'c:\mp3\music.mp3' );
action: Gets info about the current playing song. The value it returns depends on the value of 'argument'. argument: 0 Samplerate (i.e. 44100), 1 Bitrate (i.e. 128), 2 Channels (i.e. 2) return: Info or 0 on error. example: $winamp->getinfo( a => 0 );
action: Fades out current song and stops playing. argument: none. return: 0 on error, 1 otherwise example: $winamp->fadeoutandstop;
action: Toggle shuffle on and off. argument: 0 Turn shuffle off, 1 Turn shuffle on return: 1 if shuffle is on, 0 otherwise example: $winamp->shuffle( a => 0 );
action: Gets the status of shuffle button. argument: none. return: 1 if shuffle is on, 0 otherwise. example: $winamp->shuffle_status;
action: Toggle repeat on and off. argument: 0 Turn shuffle off, 1 Turn shuffle on return: 1 if repeat is on, 0 otherwise. example: $winamp->repeat( a => 0 );
action: Gets the status of the repeat button. argument: none. return: 1 if repeat is on, 0 otherwise example: $winamp->repeat_status;
action: Turns up the volume. argument: none. return: 1 on success, 0 otherwise example: $winamp->volumeup;
action: Turns down the volume. argument: none. return: 1 on success, 0 otherwise example: $winamp->volumedown;
action: Set the volume level. argument: 0-255 The volume level. return: 1 on success, 0 otherwise example: $winamp->setvolume( a => 100 );
action: Gets the eq data. argument: 0-9 10 bands of EQ data 10 Preamp value 11 Equalizer enabled 12 Equalizer autoload return: 0-9 0-63 (+20db - -20db) 10 0-63 (+20db - -20db) 11 Zero if disabled, nonzero if enabled. 12 Zero if disabled, nonzero if enabled. example: $winamp->geteqdata( a => 8 );
action: Sets the eq data at 'x' to 'y'. note: the argument format is ( a => 'x,y' ) x is the band. y is the value. argument: 0-9,0-63 10 bands of EQ data (0-63) 10,0-63 Preamp value (0-63) 11,0-1 Equalizer enabled (0-1) 12,0-1 Equalizer autoload (0-1) return: 1 on success,0 otherwise example: $winamp->seteqdata( a => '8,10' );
action: Gets the ID3 tag info of a file. argument: none Gets info for current playing file, or <n> gets the info for the file indexed at 'n'. return: 0 on error, otherwise returns contents of ID3 tag formated: SongName<br>Artist<br>Album<br>Year<br>Genre<br>Comment example: $winamp->getid3tag( a => 3 );
action: Gets a specific portion of the ID3 tag info from a file. argument: none Gets info for current playing file or <n> gets the info for the file indexed at 'n'. return: 0 on error, otherwise returns contents of specific portion of ID3 tag. example: $winamp->getid3tag_year( a => 3 );
action: Check a given string against the real password. argument: a string representing the password. return: 0 if incorrect, 1 otherwise. example: $winamp->validate_password( a=> 'password' );
action: Flushes the playlist cache buffer. argument: none. return: 0 on error,1 otherwise. example: $winamp->flushplaylist;
action: Returns the title of the current song from the winamp window name. Used when the playlist title is not enough. argument: none. return: 0 on error, song title otherwise. example: $winamp->getcurrenttitle;
action: Updates the information about the current title. argument: none. return: 0 on error, 1 otherwise example: $winamp->updatecurrenttitle;
action: Checks for an internet connection. argument: none. return: 1 if internect connection exists, 0 otherwise example: $winamp->internet;
action: Restarts winamp. note: If the httpQ service is not set to start automatically httpQ will be shut down. argument: none. return: 0 on error, 1 otherwise. example: $winamp->restart;
action: Returns the status of how the httpQ service starts. argument: none. return: 1 if the service is set to start automatically, 0 otherwise. example: $winamp->getautoservice;
action: Sets the flag which controls if the httpQ service will start automatically or not. argument: 1 Sets the service to start automatically, 0 Sets the service to not start automatically. return: 1 if the service is set to start automatically, 0 otherwise. example: $winamp->setautoservice( a => 1 );
action: Attempts to start the shoutcast server. argument: none. return: 1 if successful, 0 otherwise. example: $winamp->shoutcast_connect;
action: Attempts to retrieve status from shoutcast server. argument: none. return: status of shoutcast server if successful, 0 otherwise. example: $winamp->shoutcast_status;
None by default.
You will need the winamp-plugin "httpQ" (Written by Kosta Arvanitis) on the machine playing the music via winamp. You may find it via searching at the winamp headquarter:
http://www.winamp.com
Or directly from the author:
http://www.kostaa.com/winamp/
Murat Ünalan, muenalan@cpan.org
Copyright (c) 2002 Murat Uenalan. All rights reserved. Note: This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl(1).
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Ünalan,'. Assuming CP1252
To install Winamp::Control, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Winamp::Control
CPAN shell
perl -MCPAN -e shell install Winamp::Control
For more information on module installation, please visit the detailed CPAN module installation guide.