From: Lieven H. <li...@li...> - 2010-08-16 20:08:15
|
Hello, I finally found some time to continue working on the code of a module to support squeezeboxes. I almost have the very basics working: to be able to control the amp connected to the squeezebox through MH. However, there is currently one thing that is not quite OK yet. I try to monitor the state of the Squeezebox by adding the following state monitor: $$self{state_monitor} = "audio.basic : status | hbeat.app : status"; I need to parse both messages to be able to get the status of the squeezebox, as the SB emits its status through: * an xpl-trig message (when the squeezebox is shut down with the remote) * heartbeat messages (when the SB reaches the end of the current playlist it does not generate an xpl-trig, but the status of the device is correctly reported as 'paused' in the following heartbeat message). The problem is that in the xPL_Items code, there is a statement 'next unless ($className =~ /^$regex_class$/)' statement that executes the 'next' when a heartbeat message is received. I assume this is not what should happen, because there is some specific code for handling heartbeat messages some lines later. I'm currently working around this by not executing the next when $className equals hbeat.app, but I don't suppose that this is the way to go (when I need to change the code of the xPL_Items module, I'm most probably trying to use it incorrectly)... Moreover, when I do parse the heartbeat messages to get the status of the SB (with the patched version of xPL_Items), I get a 'state_now' on every heartbeat I receive, even when the status is the same as in the previous message. Is there anybody who can shine his/her light on this? I've committed the most recent version of xPL_Squeezebox.pm to the repository under 'lib' (rev 1743). Thanks, Lieven. PS. The received hbeat of the squeezebox looks like this: db1 xpl check: s=slimdev-slimserv.keuken c= t=* d=xpl-stat { hop=1 source=slimdev-slimserv.keuken target=* } hbeat.app { interval=1 port=50000 remote-ip=192.168.1.30 schema=audio.slimserv status=paused } Op 21-jun-2010, om 18:46 heeft Gregg Liming het volgende geschreven: > > On Jun 21, 2010, at 8:10 AM, Andy McCallum <myi...@st...> wrote: > >> Lieven, >> >> Sorry for the long delay in replying. I thought something like the following should work: >> my $sb_arwen_status = new xPL_Item('slimdev-slimserv.arwen'); >> $$sb_arwen_status{'state_monitor'} = 'audio.basic : status'; # noloop >> $sb_arwen_status->tie_event('print_log "sb_arwen status: " . $sb_arwen_status->state_now()'); >> >> my $sb_arwen_track = new xPL_Item('slimdev-slimserv.arwen'); >> $$sb_arwen_track{'state_monitor'} = 'audio.basic : track'; # noloop >> $sb_arwen_track->tie_event('print_log "sb_arwen playing track: " . $sb_arwen_track->state_now()'); >> >> >> It does not.... which means we have to ask Gregg Liming who is our xPL guru and has helped me many a time. Hopefully he will hear our cry for help. >> > > Hey guys. Am away from my computer; so will need to wait until the 28th for me to provide some options. > >> In the mean time, have a play with the code below. Using it you can certainly make achieve what you need, but with a little bit of kludging.... >> >> $ProjAV = new xPL_Item('slimdev-slimserv.arwen'); >> $ProjAV->class_name('audio.basic'); >> $ProjAV->tie_event('print_log "ProjAV: state=".$ProjAV->state'); >> >> Andy. > |