Forum
  • Search
  • Member List
  • Calendar
Hello There, Guest! Login Register — Login with Facebook

read out XBMC play, pause stop status
Thank you for your donation

Pages (3): 1 2 3 Next »
Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode | Linear Mode
read out XBMC play, pause stop status
25th Jan, 2014, 07:56 PM
Post: #1
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 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?
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 01:12 AM
Post: #2
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
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
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 01:45 AM
Post: #3
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(26th Jan, 2014 01:12 AM)mk01 Wrote:  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
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...
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 03:26 AM
Post: #4
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
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
task

script
    case $UPSTART_EVENTS in
         screensaver)
                 ;;
         player)
                 if [ $ACTION = START ]; then
                     echo "Video Playing, dimming ligths!"
                      kaku 123 1 dim 4
                 else
                      echo "Video Stopped, brighting ligths!"
                      kaku 123 1 dim 8;
                 fi
                 ;;
         library)
                 ;;
         *)
               ;;
     esac

end script

Please read rules and do a search before you post! . FAQs . How to post log file? . Looking for answers? Please start here
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 03:44 AM
Post: #5
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(26th Jan, 2014 03:26 AM)mk01 Wrote:  then start with something like this

create /etc/init/xbmc-events.conf
Code:
start on screensaver or player or library
task

env UPSTART_EVENTS
env ACTION
env TYPE

script
    case $UPSTART_EVENT in
         screensaver)
                 ;;
         player)
                 if [ $ACTION = START ]; then
                     echo "Video Playing, dimming ligths!"
                      kaku 123 1 dim 4
                 else
                      echo "Video Stopped, brighting ligths!"
                      kaku 123 1 dim 8;
                 fi
                 ;;
         library)
                 ;;
         *)
               ;;
     esac

end script
okay, 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
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 05:17 AM
Post: #6
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
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
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 05:20 AM
Post: #7
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(26th Jan, 2014 05:17 AM)mk01 Wrote:  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

Hmm how to start te script?
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 05:23 AM
Post: #8
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
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
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 05:57 AM
Post: #9
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
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.

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

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 ?
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 05:46 PM
Post: #10
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
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?


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
26th Jan, 2014, 11:10 PM
Post: #11
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
RE: read out XBMC play, pause stop status
we forgot to make the variables available to script:

Code:
env UPSTART_EVENTS
env ACTION
env TYPE

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
Find all posts by this user
Quote this message in a reply
27th Jan, 2014, 12:53 AM
Post: #12
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(26th Jan, 2014 11:10 PM)mk01 Wrote:  we forgot to make the variables available to script:

Code:
env UPSTART_EVENTS
env ACTION
env TYPE

put it anywhere outside the "script ….. end script" definition

(i updated the original post for reference)
Find all posts by this user
Quote this message in a reply
2nd Feb, 2014, 03:42 AM
Post: #13
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(27th Jan, 2014 12:53 AM)lukeg01 Wrote:  
(26th Jan, 2014 11:10 PM)mk01 Wrote:  we forgot to make the variables available to script:

Code:
env UPSTART_EVENTS
env ACTION
env TYPE

put it anywhere outside the "script ….. end script" definition

(i updated the original post for reference)
It still doesn't work?
Where to put the log rule, then i can see if it at least recieve the status change
Find all posts by this user
Quote this message in a reply
3rd Feb, 2014, 06:32 AM
Post: #14
mk01 Offline
Registered
Posts: 2,485
Joined: Mar 2013
Reputation: 209
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
14273.97 4753.61 stopped xbmc-events                      0.23 0.55 0.81 6/201 4939
14274.10 4753.61 started xbmc-priority                    0.23 0.55 0.81 6/201 4953
14274.26 4753.61 stopped xbmc-screensaver                 0.23 0.55 0.81 4/197 4961
14274.38 4753.61 stopped xbmc-priority                    0.23 0.55 0.81 3/195 4966
14352.33 4764.25 started xbian-xbmc-player                1.46 0.81 0.88 5/209 5018
14352.34 4764.25 started xbmc-events                      1.46 0.81 0.88 4/206 5018
14352.48 4764.25 stopped xbmc-events                      1.46 0.81 0.88 4/204 5023
14352.67 4764.25 started xbmc-priority                    1.46 0.81 0.88 4/206 5030
14352.96 4764.25 stopped xbmc-priority                    1.59 0.85 0.89 3/204 5036
14358.65 4764.25 stopped xbian-xbmc-player                1.62 0.87 0.89 6/206 5049
14358.66 4764.25 started xbmc-events                      1.62 0.87 0.89 6/206 5049
14358.82 4764.25 stopped xbmc-events                      1.62 0.87 0.89 5/201 5054

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
Find all posts by this user
Quote this message in a reply
4th Feb, 2014, 04:07 AM
Post: #15
lukeg01 Offline
Registered
Posts: 77
Joined: Dec 2013
Reputation: 1
RE: read out XBMC play, pause stop status
(3rd Feb, 2014 06:32 AM)mk01 Wrote:  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
14273.97 4753.61 stopped xbmc-events                      0.23 0.55 0.81 6/201 4939
14274.10 4753.61 started xbmc-priority                    0.23 0.55 0.81 6/201 4953
14274.26 4753.61 stopped xbmc-screensaver                 0.23 0.55 0.81 4/197 4961
14274.38 4753.61 stopped xbmc-priority                    0.23 0.55 0.81 3/195 4966
14352.33 4764.25 started xbian-xbmc-player                1.46 0.81 0.88 5/209 5018
14352.34 4764.25 started xbmc-events                      1.46 0.81 0.88 4/206 5018
14352.48 4764.25 stopped xbmc-events                      1.46 0.81 0.88 4/204 5023
14352.67 4764.25 started xbmc-priority                    1.46 0.81 0.88 4/206 5030
14352.96 4764.25 stopped xbmc-priority                    1.59 0.85 0.89 3/204 5036
14358.65 4764.25 stopped xbian-xbmc-player                1.62 0.87 0.89 6/206 5049
14358.66 4764.25 started xbmc-events                      1.62 0.87 0.89 6/206 5049
14358.82 4764.25 stopped xbmc-events                      1.62 0.87 0.89 5/201 5054

JUST ONE CORRECTION INDEED:

case $UPSTART_EVENT in => case $UPSTART_EVENTS in

eventS, not event. everywhere else is correct.

i got
Code:
173.68 0.61 started xbian-xbmc-player                2.83 1.59 0.63 7/203 2660
173.68 0.61 started xbmc-events                      2.83 1.59 0.63 7/203 2660
173.89 0.61 stopped xbmc-events                      2.83 1.59 0.63 6/201 2664
174.17 0.61 started xbmc-priority                    2.83 1.59 0.63 7/203 2670
174.79 0.61 stopped xbmc-priority                    2.83 1.59 0.63 5/202 2678
257.74 0.61 stopped xbian-xbmc-player                3.57 2.16 0.92 6/204 3278
257.76 0.61 started xbmc-events                      3.57 2.16 0.92 5/204 3278
257.96 0.61 stopped xbmc-events                      3.57 2.16 0.92 5/202 3282
258.20 0.61 started xbmc-priority                    3.57 2.16 0.92 4/203 3288
258.65 0.61 stopped xbmc-priority                    3.57 2.16 0.92 4/201 3295
but loggin in /tmp/ does not work.... i have put it between [script] and [case]
Find all posts by this user
Quote this message in a reply
« Next Oldest | Next Newest »
Pages (3): 1 2 3 Next »
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
  [IDEA] Start/stop XBMC from web gui Fred 8 30,948 11th Apr, 2013 10:41 PM
Last Post: wuschl

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:

Current time: 9th May, 2025, 07:05 AM Powered By MyBB, © 2002-2025 MyBB Group.