Req Stop playback when television switched off
#1
In the Kodi Menu System -> Input -> CEC I can select what happens when the television is switched off. I can select either shutdown or suspend. Neither of those choices is an option with the RaspberriPi because suspend is not supported and shutdown is a bad idea since you can't boot it without plugging power.

So I let my pi with OpenElec run 24/7 but at least I want to make sure that the playback, especially in case of broadcasting, stops after switching the TV off. It would be nice if you add an option to stop playback when the TV is switched off.
Reply
#2
Moving this to the correct forum...
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
Reply
#3
1+ for this request


@athei, have a look at this: http://forum.kodi.tv/showthread.php?tid=229327.

It's not what you asked for, e.g it wont stop playback with CEC, but it is a timer, that will stop the stream... I have a daughter that uses a RPI2 and watches TV using the MythTV addon.. she would often turn the TV off but leave the stream running... which meant the stream was constanlty being recorderd on my backend - not a big problem, but i just didnt like the idea...

With this addon it will turnoff the stream at set time when there's been no interaction - i've set mine at 4 hours i think
Reply
#4
Should be quiet simple to add, but I think we will need a libCEC change/feature for it to be clean code.
Needs to be added here https://github.com/xbmc/xbmc/blob/f8c153...r.cpp#L631
and in some xmls then.
Reply
#5
a colleague of mine is actually working on this. No ETA though, since its his first ever try at kodi
Reply
#6
That sounds good. Maybe can drop a message here when the feature is done Smile
Reply
#7
Exclamation 
+1 request

Duplicates:
http://forum.kodi.tv/showthread.php?tid=212721
http://forum.kodi.tv/showthread.php?tid=168709
http://forum.kodi.tv/showthread.php?tid=247464

I created a patch, but i can not build patched kodi from source (and don't know, how it works).
wsnipex, please, add this feature. It's very useful for cec users.

Link to patch: https://dl.dropboxusercontent.com/u/3303..._off.patch
I'm not sure about the call Action(Stop), maybe need other method here.

Updated 14.12.2015:
I built patched Kodi. Everything works, but there is a problem with the display and update settings.
New patch: https://dl.dropboxusercontent.com/u/3303...2015.patch

Manual for Ubuntu:
PHP Code:
apt-get source kodi
sudo apt-get build-dep kodi
cd kodi_15.2~git20151019.1039-final/
mkdir debian/patches

Then download two files into debian
/patches/:
https://dl.dropboxusercontent.com/u/33039414/stop_playback_when_tv_off_14.12.2015.patch
https://dl.dropboxusercontent.com/u/33039414/series

dpkg-buildpackage
sudo dpkg -../kodi-bin_15.2~git20151019.1039-final-0trusty_amd64.deb
sudo dpkg -../kodi_15.2~git20151019.1039-final-0trusty_all.deb 
Reply
#8
I found interesting solution.
I powered it from TVs usb Smile
Reply
#9
(2016-09-03, 20:06)Winters Wrote: I found interesting solution.
I powered it from TVs usb Smile

That's probably not the best solution for two reasons:
1. Your Pi will suddenly lose power, which can cause your sd card to become corrupted.
2. Your TVs USB ports probably don't output 2A+, which is recommended for the Pi to work properly.

A Logitech Harmony could solve your problem!
Reply
#10
(2016-09-03, 20:06)Winters Wrote: I found interesting solution.
I powered it from TVs usb Smile

Is there a setting to stop playback when the pulse-eight adapter is turned off?
Reply
#11
I really also wanted this feature but found out that none of the suggested solutions are ideal. I wanted to stop the Live TV almost instantly when TV is switched off. I tried to see if commands tvservice -s or fbset return any different information when the TV is on or off but those returned same output regardless if the TV was on or off.

However, I found out one easy solution that works if you have connected the Kodi via HDMI to a receiver which has network connection and you have connected the receiver to your local network. You can simply monitor when your receiver stops responding to ping and then call Kodi with JSON-RPC API to stop playback.

For example, my receiver has IP 192.168.1.111 and I have enabled HTTP JSON RPC from kodi settings (see this: http://kodi.wiki/view/JSON-RPC_API ). I have then added the following script via SSH to system running Kodi to /storage/scripts/detect_tv_off.sh

Code:
#!/bin/bash
if ping -c 1 -W 1 192.168.1.111 >/dev/null; then
  echo "$(date -Iseconds): TV is on. Doing nothing."
else
  echo "$(date -Iseconds): TV is off. Stop Kodi playback."
  curl -H "Content-Type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": 1 }, "id": "mybash"}' http://username:[email protected]:8080/jsonrpc
  echo ""
fi

Then with crontab -e, I modified crontab to have these:
Code:
0 3 * * * echo "$(date -Iseconds): Log cleared" > /storage/scripts/detect_tv_off.log >/dev/null 2>&1
* * * * * /storage/scripts/detect_tv_off.sh >> /storage/scripts/detect_tv_off.log

So every minute, the script checks whether the receiver responds to ping, if not it calls Kodi to stop playback. This works well for me since when I stop watching TV, I switch off the receiver. Now I don't have to remember to press stop from my remote but within one minute playback will be automatically stopped.

EDIT: Also I found out that there is command line tool cec-client which could also work to detect if TV is off and then one could run the same JSON RPC command to Kodi to stop playback. But using ping in this case is much more simpler.
Reply
#12
Solution found in this post:

https://discourse.osmc.tv/t/cec-options-...menu/38675
Reply

Logout Mark Read Team Forum Stats Members Help
Stop playback when television switched off1