read out XBMC play, pause stop status
|
25th Jan, 2014, 07:56 PM
Post: #1
|
|||
|
|||
read out XBMC play, pause stop status
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? |
|||
26th Jan, 2014, 01:12 AM
Post: #2
|
|||
|
|||
RE: read out XBMC play, pause stop status
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 Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
26th Jan, 2014, 01:45 AM
Post: #3
|
|||
|
|||
RE: read out XBMC play, pause stop status
(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... |
|||
26th Jan, 2014, 03:26 AM
Post: #4
|
|||
|
|||
RE: read out XBMC play, pause stop status
then start with something like this
create /etc/init/xbmc-events.conf Code: start on screensaver or player or library Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
26th Jan, 2014, 03:44 AM
Post: #5
|
|||
|
|||
RE: read out XBMC play, pause stop status
(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 |
|||
26th Jan, 2014, 05:17 AM
Post: #6
|
|||
|
|||
RE: read out XBMC play, pause stop status
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 Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
26th Jan, 2014, 05:20 AM
Post: #7
|
|||
|
|||
RE: read out XBMC play, pause stop status
(26th Jan, 2014 05:17 AM)mk01 Wrote: yes. you got the point. Hmm how to start te script? |
|||
26th Jan, 2014, 05:23 AM
Post: #8
|
|||
|
|||
RE: read out XBMC play, pause stop status
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 Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
26th Jan, 2014, 05:57 AM
Post: #9
|
|||
|
|||
RE: read out XBMC play, pause stop status
(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 ? |
|||
26th Jan, 2014, 05:46 PM
Post: #10
|
|||
|
|||
RE: read out XBMC play, pause stop status
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? |
|||
26th Jan, 2014, 11:10 PM
Post: #11
|
|||
|
|||
RE: read out XBMC play, pause stop status
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) Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
27th Jan, 2014, 12:53 AM
Post: #12
|
|||
|
|||
RE: read out XBMC play, pause stop status | |||
2nd Feb, 2014, 03:42 AM
Post: #13
|
|||
|
|||
RE: read out XBMC play, pause stop status
(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 |
|||
3rd Feb, 2014, 06:32 AM
Post: #14
|
|||
|
|||
RE: read out XBMC play, pause stop status
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. Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here |
|||
4th Feb, 2014, 04:07 AM
Post: #15
|
|||
|
|||
RE: read out XBMC play, pause stop status
(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 |
|||
« Next Oldest | Next Newest »
|
Possibly Related Threads... | |||||
Thread: | Author | Replies | Views: | Last Post | |
[IDEA] Start/stop XBMC from web gui | Fred | 8 | 29,952 |
11th Apr, 2013 10:41 PM Last Post: wuschl |