Hello. I have an audio system throughout my house and have set up a driveway alarm from a security camera to watch for motion and play a tune over my squeezebox if someone drives down the driveway. What I want to happen is, if music is playing, that it stops, the tune plays, and it continues. If no music is playing, it just plays the tune. I am trying to set this up through the Command Line Interface (CLI) in Logitech Media Server. What I have done so far is as follows:
driveway.bat file:
nc 192.168.1.16 9090 < driveway.txt
ping 1.1.1.1 -n 1 -w 4000 > nul
nc 192.168.1.16 9090 < driveway2.txt
The 'nc' program above is NetCat, a Telnet program that I can redirect text into for automation from the driveway.txt and driveway2.txt files.
The "Ping 1.1.1.1 -n 1 -w 4000 > nul" is just a wait command to wait 4 seconds before proceeding so that my tune has time to play. There may be a better way to do this, but this was the best I could find.
Inside of the driveway.txt file I have:
00:04:20:09:05:5f playlist save current
00:04:20:09:05:5f playlist play driveway
exit
I have "driveway" set up in my playlists which is the audio I am wanting to play.
Then, in driveway2.txt, I have:
00:04:20:09:05:5f playlist resume current
So, everything works well with one exception, and that is that if the player is paused when the driveway alarm goes off, when it gets to the "playlist resume" command, the music starts playing. I need it to only resume the music playing if it was playing in the first place. So, I seem to have the choices of 1. If the music is playing when the driveway alarm goes off, without the resume command the music stops, or 2. If the music is not playing with the resume command, it starts playing even through it wasn't playing in the first place. There must be some way to only resume the music if it was actually playing in the first place, but darn if I can figure out how to do it. Any experts out there know how?
Thank you.
Sean Dudley
Results 1 to 5 of 5
-
2013-08-15, 13:10 #1
- Join Date
- Aug 2013
- Posts
- 5
Trying to play a temporary sound and then resume playing of music if it was playing.
-
2013-08-15, 17:23 #2
- Join Date
- Aug 2012
- Location
- Austria
- Posts
- 1,190
check the status of the player with "<playerid> mode ?". If it's paused, don't execute the second nc command
you might want to use the timeout command instead of the pingVarious SW: Web Interface | TUI | Playlist Editor / Generator | Music Classification | Similar Music | Announce | EventTrigger | DB Optimizer | Chiptunes | LMSlib2go | ...
Various HowTos: build a self-contained LMS | Bluetooth/ALSA | Control LMS with any device | ...
-
2013-08-15, 19:14 #3
- Join Date
- Aug 2013
- Posts
- 5
-
2013-08-16, 04:39 #4
- Join Date
- Aug 2013
- Posts
- 5
Got it working.
With your help, I got it going. Thought I'd post exactly how I got it working for anybody else who is trying to figure it out. I have 2 squeezeboxes. I have programmed this to resume the music, including to the point in the song where it was at when the tune played.
In my file I execute, driveway.bat, I ended up with the following:
nc 192.168.1.16 9090 < checkifplaying1.txt > status1
nc 192.168.1.16 9090 < checktime1.txt > time1
nc 192.168.1.16 9090 < checkifplaying2.txt > status2
nc 192.168.1.16 9090 < checktime2.txt > time2
nc 192.168.1.16 9090 < driveway.txt
timeout /t 5 /nobreak
seek32 /s status1 "mode play"
if errorlevel 1 goto player1resume
goto player2
: player1resume
nc 192.168.1.16 9090 < driveway-player1-resume.txt
split32 time1 toutput1 "time "
copy player1-mac.txt+toutput1+exit.txt timeres1.txt
nc 192.168.1.16 9090 < timeres1.txt
: player2
seek32 /s status2 "mode play"
if errorlevel 1 goto player2resume
goto end
: player2resume
nc 192.168.1.16 9090 < driveway-player2-resume.txt
split32 time2 toutput2 "time"
copy player2-mac.txt+toutput2+exit.txt timeres2.txt
nc 192.168.1.16 9090 < timeres2.txt
:end
if exist toutput1 del toutput1
if exist toutput2 del toutput2
seek32 is a 3rd party DOS program which does pretty much the same thing as the DOS FIND program, except for some reason the DOS find program under Windows 7 refuses to return the error codes. Split32.exe is a 3rd party DOS program to split a file at the point where you tell it to do so. I downloaded seek32.exe and split32.exe in a suite of DOS utilities from the site clayruth.com. nc above is a 3rd party program called NetCat which allows redirecting of text to and from a telnet session which the DOS telnet does not allow.
checkifplaying1.txt and checkifplaying2.txt (with their respective mac addresses):
xx:xx:xx:xx:xx:xx mode ?
exit
checktime1.txt and checktime2.txt (with their respective mac addresses):
xx:xx:xx:xx:xx:xx time ?
exit
driveway.txt:
00:04:20:12:12:dd playlist save current1
00:04:20:09:05:5f playlist save current2
00:04:20:12:12:dd playlist play driveway
00:04:20:09:05:5f playlist play driveway
exit
player1-mac.txt and player2-mac.txt with their respective MAC addresses:
xx:xx:xx:xx:xx:xx
(note: there must be a space at the end of the MAC address)
driveway-player1-resume.txt and driveway-player2-resume.txt (with their respective mac addresses):
xx:xx:xx:xx:xx:xx playlist resume current1
exit
exit.txt:
exit
(must have an carriage return after it.)
Sean DudleyLast edited by seandudley; 2013-08-16 at 08:38. Reason: Your site changed things like :player resume to a smily face at the beginning. Had to add a space in there.
-
2013-08-16, 10:25 #5
- Join Date
- Aug 2013
- Posts
- 5
Modificatiion for using MOG
I found that the seek to current time part wasn't working with MOG because the command to tell it to do the seek was happening before MOG had responded and brought the song back up. Initially I just put in a 2 second delay after the command to start playing the song again to get around this issue, but then you would hear the song start over again for a second or less and then it would skip to the correct position. Thus, I did some more coding to eliminate the song playing over from the beginning at all. It does take a few seconds longer for the music to start playing again if you are listening to Mog than other services due to the necessary delays. Here is the MOG modified version of the main batch file (which I have named driveway.bat):
nc 192.168.1.16 9090 < checkifplaying1.txt > status1
nc 192.168.1.16 9090 < checktime1.txt > time1
nc 192.168.1.16 9090 < checkifplaying2.txt > status2
nc 192.168.1.16 9090 < checktime2.txt > time2
nc 192.168.1.16 9090 < driveway.txt
timeout /t 5 /nobreak
nc 192.168.1.16 9090 < driveway-player1-resume.txt
seek32 /s status1 "mode play"
if errorlevel 1 goto player1resume
goto player2
: player1resume
split32 time1 toutput1 "time "
copy player1-mac.txt+toutput1+exit.txt timeres1.txt
split32 time1 toutput1 "time "
copy player1-mac.txt+toutput1+exit.txt timeres1.txt
seek32 /s c:\Users\Sean\Music\Playlists\current1.m3u ":mog:"
if errorlevel 1 goto player1mog
goto skipmog1
: player1mog
timeout /t 2 /nobreak
: skipmog1
nc 192.168.1.16 9090 < player1-play.txt
seek32 /s c:\Users\Sean\Music\Playlists\current1.m3u ":mog:"
if errorlevel 1 goto player1mog-2
goto skipmog1-2
: player1mog-2
timeout /t 1 /nobreak
: skipmog1-2
nc 192.168.1.16 9090 < timeres1.txt
: player2
nc 192.168.1.16 9090 < driveway-player2-resume.txt
seek32 /s status2 "mode play"
if errorlevel 1 goto player2resume
goto end
: player2resume
split32 time2 toutput2 "time"
copy player2-mac.txt+toutput2+exit.txt timeres2.txt
seek32 /s c:\Users\Sean\Music\Playlists\current2.m3u ":mog:"
if errorlevel 1 goto player2mog
goto skipmog2
: player2mog
timeout /t 2 /nobreak
: skipmog2
nc 192.168.1.16 9090 < player2-play.txt
seek32 /s c:\Users\Sean\Music\Playlists\current2.m3u ":mog:"
if errorlevel 1 goto player2mog-2
goto skipmog2-2
: player2mog-2
timeout /t 1 /nobreak
: skipmog2-2
nc 192.168.1.16 9090 < timeres2.txt
:end
if exist toutput1 del toutput1
if exist toutput2 del toutput2Last edited by seandudley; 2013-08-19 at 10:49.