read out XBMC play, pause stop status - Printable Version +- Forum (http://forum.xbian.org) +-- Forum: Software (/forum-6.html) +--- Forum: Testing & Experimental (/forum-21.html) +--- Thread: read out XBMC play, pause stop status (/thread-2055.html) |
read out XBMC play, pause stop status - lukeg01 - 25th Jan, 2014 07:56 PM hello, i'm working on comining home automitation and media, i found this little script #!/bin/bash xbmcurl="http://pc-tv/jsonrpc" previousvideoplaying=0 while [ 1 ] do wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1}' $xbmcurl | grep -v '"video"' > /dev/null video=$? wget -q -O- --header='Content-Type: application/json' --post-data='{"jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 1, "properties": ["speed"] }, "id": 1}' $xbmcurl | grep '"speed":0' > /dev/null playing=$? #echo "video=$video playing=$playing" if [ $video == 1 ] && [ $playing = 1 ]; then # echo "Video Playing!" if [ $previousvideoplaying == 1 ]; then echo "Video Playing, dimming ligths!" kaku 123 1 dim 4 fi previousvideoplaying=1 else if [ $previousvideoplaying == 1 ]; then echo "Video Stopped, brighting ligths!" kaku 123 1 dim 8; previousvideoplaying=0 fi done it only keeps saying "video playing, dimming lights" and dimm my light, i'm running 433Mhzdeamon in no hup ( https://github.com/jeroensteenhuis/433mhzforrpi ) am i missing anything? RE: read out XBMC play, pause stop status - mk01 - 26th Jan, 2014 01:12 AM luke, XBian has in core system whole workflow already based on XBMC events. check /var/log/upstart-xbmc-bridge.log file and you will see generated upstart events. line like this Code: 23/01/2014 20:53:08 Send event: ['initctl', 'emit', '-n', 'player', 'ACTION=STOP', 'TYPE=episode'] means there was generated event "player" with action "stop" and the played item was "episode" (tv show). check Code: /usr/local/sbin/upstart-xbmc-bridge.py for short howto RE: read out XBMC play, pause stop status - lukeg01 - 26th Jan, 2014 01:45 AM (26th Jan, 2014 01:12 AM)mk01 Wrote: luke,okay, i'm terrible noob, if you can please make me a verry basic script, i can fill it with thing i learned from xbmc-bridge but i dont think i can do it alone... RE: read out XBMC play, pause stop status - mk01 - 26th Jan, 2014 03:26 AM then start with something like this create /etc/init/xbmc-events.conf Code: start on screensaver or player or library RE: read out XBMC play, pause stop status - lukeg01 - 26th Jan, 2014 03:44 AM (26th Jan, 2014 03:26 AM)mk01 Wrote: then start with something like thisokay, how to start it? sudo ./ says commands not found when i took a look at the event file i saw you could specify the type playing (tv show movie audio) then i can set that playing movie won't kill the lights, and if i want to set another value like pause , would it be if [ $ACTION = START ]; then echo "Video Playing, dimming ligths!" kaku 123 1 dim 4 elseif [$ACTION = PAUSE]; then echo "video paused, brighting lights!" kaku 123 1 dim 7 else echo "Video Stopped, brighting ligths!" kaku 123 1 dim 8; fi i know that in this case it doesn't matter much but its more for understanding what i write... Thanks a lot RE: read out XBMC play, pause stop status - mk01 - 26th Jan, 2014 05:17 AM yes. you got the point. it is more than likely that there are even more types XBMC is sending, … you can put before the "case" statement like: Code: echo "$(date) $UPSTART_EVENTS $ACTION $TYPE >> /tmp/events.log and you will see all what you received RE: read out XBMC play, pause stop status - lukeg01 - 26th Jan, 2014 05:20 AM (26th Jan, 2014 05:17 AM)mk01 Wrote: yes. you got the point. Hmm how to start te script? RE: read out XBMC play, pause stop status - mk01 - 26th Jan, 2014 05:23 AM there is nothing to start. it will be started when needed. XBMC send event -> xbmc-bridge-upstart.py receives -> xbmc-bridge-upstart.py transforms and created UPSTART event -> upstart knows from the .conf file that that one is interested in events screensaver, player, library and will run the script. the script will immediately finish and wait for next event RE: read out XBMC play, pause stop status - lukeg01 - 26th Jan, 2014 05:57 AM (26th Jan, 2014 05:23 AM)mk01 Wrote: there is nothing to start. it will be started when needed. Hmmm il try again tomorrow didnt't work, maybe a typo in the command... And how to specify play type (audio movie tv show) Edit: shouldn't there be a ";" after the first time dim 4 ? RE: read out XBMC play, pause stop status - lukeg01 - 26th Jan, 2014 05:46 PM Olay, i edited the script with the given log code ( i only changed it to log to my home dir) It's added with this post, did I do it wrong , it doesn't make a log after watching a movie? RE: read out XBMC play, pause stop status - mk01 - 26th Jan, 2014 11:10 PM we forgot to make the variables available to script: Code: env UPSTART_EVENTS put it anywhere outside the "script ….. end script" definition (i updated the original post for reference) RE: read out XBMC play, pause stop status - lukeg01 - 27th Jan, 2014 12:53 AM (26th Jan, 2014 11:10 PM)mk01 Wrote: we forgot to make the variables available to script: RE: read out XBMC play, pause stop status - lukeg01 - 2nd Feb, 2014 03:42 AM (27th Jan, 2014 12:53 AM)lukeg01 Wrote:It still doesn't work?(26th Jan, 2014 11:10 PM)mk01 Wrote: we forgot to make the variables available to script: Where to put the log rule, then i can see if it at least recieve the status change RE: read out XBMC play, pause stop status - mk01 - 3rd Feb, 2014 06:32 AM check /run/upstart-ev.log in that file you will see EACH job and its state changes when triggered. that means, you should at least see that it is being called. I just copied the script from my post #5, saved under the name as shown there and started a video. immediately I have events generated. Code: 14273.86 4753.61 started xbmc-events 0.23 0.55 0.81 4/197 4929 JUST ONE CORRECTION INDEED: case $UPSTART_EVENT in => case $UPSTART_EVENTS in eventS, not event. everywhere else is correct. RE: read out XBMC play, pause stop status - lukeg01 - 4th Feb, 2014 04:07 AM (3rd Feb, 2014 06:32 AM)mk01 Wrote: check /run/upstart-ev.log i got Code: 173.68 0.61 started xbian-xbmc-player 2.83 1.59 0.63 7/203 2660 |