How can I determine if a stream is playing? (not if the server is running).
I want to monitor the stream, and if nothing is playing for 30 minutes, put the computer to sleep.
I see that the Squeezebox MySQL cache is updated when a new song is played, so I can watch this and if it is not updated in the last 30 minutes, sleep (...or if it has been updated, launch a program like Jiggler to prevent sleep). But this does not work for Internet Streams (plus there must me a better way).
So, what is the best way to determine if a stream is playing?
Thanks,
Results 1 to 10 of 24
-
2010-07-07, 08:16 #1
How to determine if a stream is playing
Tony
SBTouch ♪ SBRadio ♬
-
2010-07-07, 08:22 #2
Check out the ServerPowerControl plugin, starting with the very long thread in the 3rd Party Plugins forum. It will do exactly what you're asking for: monitor your SBs and send a suspend, hibernate, or shutdown command to the server computer after a user-specified period of SB inactivity. It can even optionally switchover to mysb.com before suspending the server. And if you're looking to roll your own custom suspend function, Gordon has probably worked out the details you need.
-
2010-07-07, 09:03 #3
I did, but it is overkill for my needs.
All I need to know is how to determine that a player is playing and I can use a simple launchd to monitor it and act accordingly.Tony
SBTouch ♪ SBRadio ♬
-
2010-07-07, 09:13 #4
-
2010-07-07, 09:17 #5
Thanks, I'll just post a question in that thread.
Tony
SBTouch ♪ SBRadio ♬
-
2010-07-07, 16:29 #6
Found it (I just searched for 'play') http://forums.slimdevices.com/showpo...postcount=1352
I can use the CLI to test if any of my players are in mode: 'play', and if so, I'll run Jiggler to keep my server from sleeping. I can do this with a bash script run every 9 minutes with launchdLast edited by Tony T; 2010-07-07 at 18:41.
Tony
SBTouch ♪ SBRadio ♬
-
2010-07-07, 18:39 #7
For a Mac, the following script will determine if a player is in play mode, and if so, move the mouse to prevent the Mac from sleeping:
Run with launchd, and match the time to the sleep setting in the Energy Saver System Preferences (i.e., if set to sleep after 10 minutes of inactivity, set launchd to run every 9 minutes (540 seconds) [Edit: With Lion, for some unknown reason, I had to change the time to 1 minute (60 seconds)]Code:#!/bin/bash playerCount=$(printf "player count ?\nexit\n" | nc localhost 9090 | cut -d ' ' -f 3) while [ $playerCount -gt 0 ]; do let playerCount-- playerID=$(printf "player id "$playerCount" ?\nexit\n" | nc localhost 9090 | cut -d ' ' -f 4 | sed 's/%/%%/g') playermode=$(printf "$playerID mode ?\nexit\n" | nc localhost 9090 | cut -d ' ' -f 3) if [ "$playermode" = "play" ] ; then python <<-END import time from Quartz.CoreGraphics import * def mouseEvent(type, posx, posy): theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft) CGEventPost(kCGHIDEventTap, theEvent) def mousemove(posx,posy): mouseEvent(kCGEventMouseMoved, posx,posy); ourEvent = CGEventCreate(None); currentpos=CGEventGetLocation(ourEvent); mousemove(10,10); time.sleep(1); # delay so that you can see the mouse move. Can be removed (along with import time) mousemove(int(currentpos.x),int(currentpos.y)); END break fi done
Name the following something descriptive (i.e. com.tony.MoveMouse.plist) and place in $HOME/Library/LaunchAgents/ and the above script in your Scripts directory
(...and change Users/Tony to your user name) Also, you must log-out and back-in for launcd to take effect.
Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.tonyt.MoveMouse</string> <key>ProgramArguments</key> <array> <string>/Users/Tony/Library/Scripts/Jiggle.sh</string> </array> <key>StartInterval</key> <integer>60</integer> </dict> </plist>
Last edited by Tony T; 2011-08-15 at 16:28. Reason: added mouse move, no need for Jiggler
Tony
SBTouch ♪ SBRadio ♬
-
2010-07-08, 21:56 #8Banned
- Join Date
- Feb 2008
- Location
- flat rock community, ga
- Posts
- 2,169
Hey Tony T: I like the Vaughn Bode
p
-
2010-07-09, 04:50 #9
Are you referring to "Opus"? (that's Berkeley Breathed)
Tony
SBTouch ♪ SBRadio ♬
-
2010-12-08, 11:37 #10Senior Member
- Join Date
- Mar 2008
- Posts
- 112
Just found a bug with my Snow Leopard standard install where the nc localhost command in the script above didn't returned anything so, $playerCount stayed empty all the time. Changing localhost to the IP address of the server fixed that. I know that localhost must work and can be adjusted but just FYI as again, this was a SL install out of the box, so may happen to others..

Reply With Quote

