Post Thu Aug 22, 2013 8:31 pm

Son Bravia KDL40EX720 cannot find Serviio

Hello,
Thanks for some great software! It has worked great for me, except for one thing:

I have Serviio connected to a Sony TV via an old Macbook Pro. Everything works great when both systems are turned on at the same time. But if someone turns off the TV, leaving the computer on, the TV cannot find Serviio when it is turned back on. The TV is connected to the Macbok through an ethernet cable, and both systems have fixed IP addresses. The computer also connects to the internet through its wireless network board.

After experimenting a bit, i came up with an applescript that solves the problem. I'm posting it here in case someone else has the same problem.

What the script does: It takes the rough approach of pinging the TV. If the TV does not respond, the script kills Serviio. It continues to ping automatically every 5 s, using the "on idle" mechanism in Applescript. This keeps the system normally responsive and there is almost zero load from the script.

When the TV start responding to the ping again, the script starts Serviio. The script must be saved as a stay-open application. Make sure the script starts when the user logs in (go to System Preferences --> Accounts --> Login items, and add the script to the list).

(*
This is saved as a stay-open application. The 'on idle' thing will run repeatedly, pinging the TV to check if it is alive or not. If it is on, we start serviio. If it off, we quite serviio if it is running.
*)
global mycmd

on run
set mycmd to "ping -t 1 -c 1 192.168.2.2"
idle
end run

on idle
try
set response to do shell script mycmd
on error errorMessage number errorNumber
if (do shell script "ps -ax") contains "Serviio.app" then
do shell script "/usr/bin/killall JavaApplicationStub&"
end if
return 5
end try
if (do shell script "ps -ax") contains "Serviio.app" then
return 5
else
do shell script "/Applications/Serviio.app/Contents/MacOS/JavaApplicationStub > /dev/null 2>&1 &"
return 5
end if
end idle