SqueezeboxCLI.pm |
The module enables control of a Squeezebox device through the CLI (command line interface) of the Squeezebox server (a.k.a. Logitech Media server).
This module connects to the Squeezebox server through the telnet interface. The following preparations need to be done to get the code up and running:
Create the Squeezebox devices in the mht file or in user code:
Note: [parameters] are optional.
.mht file:
CODE, require SqueezeboxCLI; #noloop
CODE, $squeezecenter = new SqueezeboxCLI_Interface('hostname'); #noloop
CODE, $sb_living = new SqueezeboxCLI_Player('living', $squeezecenter, [coupled_device], [auto_off_time]); #noloop
CODE, $sb_kitchen = new SqueezeboxCLI_Player('kitchen', $squeezecenter, [coupled_device], [auto_off_time]); #noloop
Optional parameters:
To play a file or URL from your user code you can use this function call:
$sb_kitchen->play_notification('/Volumes/Media/speech/test1.wave');
For additional debugging, add the option squeezeboxcli:3 to the 'debug' entry to your mh.ini.private file.
This module allows to control and to monitor the state over a Squeezebox player through the telnet command line interface of the server. It also allows you to play notifications. Notifications can either be local files or URLs.
URI::Escape - The CLI interface uses an escaped format
new(name, interface, amplifier, auto_off_time)
Creates a Squeezebox_Player object. The following parameter are required:
The following parameters are optional
process_cli_response()
Interprete the data that is received from the CLI interface. Called from the gateway module.
default_setstate()
Handle state changes of the Squeezeboxes
addStates()
Add states to the device
couple_device(amplifier)
Couple another MisterHouse object to the Squeezebox device so that this device follows the state of the Squeezebox. This can e.g. be used to switch an amplifier on when the Squeezebox starts playing.
play_notification(notification, <optional_volume
)>Play a notification on this squeezebox. The notification can either be a file or an URL. This function stops the current playback, plays the notification and then returns the Squeezebox to the previous state. Credits to @rudybrian for writing the first version of this code and his permission to re-use it!
You can pass an extra parameter <volume> that is used for the notification.
Note: currently this function does not support multiple notifications being pushed at the same time
play(media, [volume])
Changes the playlist to a new media file
Parameters are the media (a file or an URL) and optionally the volume at which to play the media.
play_playlist(name, [volume])
Changes the playlist to a new playlist.
Parameters are the playlist name and optionally the volume at which to play the media.
save_sb_state
Saves the current state of the Squeezebox so that it can be restored later
restore_sb_state
Resume the Squeezebox state from the previously saved state
send_cmd(command)
Helper function to send a command to the squeezebox over the CLI
Hey! The above document had some coding errors, which are explained below:
'=item' outside of any '=over'
=over without closing =back
SqueezeboxCLI.pm |