How to determine what XBMC is doing?
#1
Sometimes it would be helpful to get the current status uf XBMC, so that other programs can perform actions accordingly.

For instance, at this point of time there is no possiblity to start directly a slideshow everytime XBMC is playing music. A work around would be, that the user initiates the slideshow with a hotkey once the music is playing.

However, what also could be done as a workaround until this possiblity exists is that a program hits the specific hotkey as soon as XBMC plays music, and thereby starts the visualization.

Or, a program shuts down the computer if XBMC is idling too long.

Unfortunately, i have not found a way to determine what XBMC is doing, for instance a log-file with the following content:

"Playing Music:
The Beatles - Yellow Submarine (C:\Music\The Beatles - Yellow Submarine.mp3)"

or

"Playing Music:
Playlist Raggae"

or

"Playing Video:
Transformers (C:\Movies\Transformers.avi)"

Is there anything like this implemented/available in XBMC? If not, would you think this would make sense?

If you think it makes sense, but its not implemented yet, a logfile with the following structure could be realized.


; ------------

Video_list: ; label of videos that are currently playing
none

current_video ; the active video
none

current_music_status ; stopped / paused / playing (time elapsed / length of video)
stopped

current_video_playlist ; if the current video is played from a playlist
none

Music_list: ; the list of the music currently playing
Red Hot Chilli Pepers - Californication (C:\Music\Red Hot Chilli Pepers - Californication.mp3) ; Following the scheme "Title - Artist (Path)"
R.E.M. - Parakeet (C:\Music\R.E.M. - Parakeet.flacc)

current_music: ; the active music title
R.E.M. - Parakeet (C:\Music\R.E.M. - Parakeet.flacc)

current_music_status ; stopped/paused / playing (time elapsed / length of song)
playing (00:03:44 / 00:04:20)

current_music_playlist ; if the current music is played from a playlist
Testplaylist

Picture_list: ; same scheme as above

current_picture: ; same scheme as above

current_picture_playlist: ; same scheme as above


;----------------------



with this kind of information, one could do quite some useful things.... but already just the information "playing music" "paused" "playing video" would be very beneficial...
Reply
#2
Yep - http://wiki.xbmc.org/index.php?title=Log_File

Hope that helps!
Image
Image
Image
Reply
#3
thank you, exactly what i was looking for! i only had to set it to "debug" and now the info is there Smile
Reply
#4
Does JSON do this? If so, that would be less tacky than reading the log file.

JR
Reply
#5
jhsrennie Wrote:Does JSON do this? If so, that would be less tacky than reading the log file.

probably a dumb question, but JSON = nickname of a programmer, or JSON = Javascript Object Notation? If latter, I dont understand the question.

but i agree, reading the entire debug-logfile is not a very elegant way...
Reply
#6
http://www.json.org/

I've played around with using JSON to send commands to XBMC. I believe, though I wouldn't swear to it, that you can use a JSON session to receive notifications from XBMC as well as send commands to it. It might be worth asking in the development forum.

JR
Reply
#7
ok thx! will have a look at it when i have some more time!
Reply
#8
Shout if you want a copy of my test Python scripts. They wouldn't form the basis of a useful application, but they show you how the protocol works (which is exactly what I wrote them for!).

JR
Reply
#9
shout ^^

never used python before - i guess i have to download the python installer 2.7.1. from http://www.python.org/ to start? (maybe i should not do that now, i should do so many other things) ^^
Reply
#10
To use JSONRPC - this connects on whatever port you've set the XBMC web server to listen on (81 in my case). Also note that 192.168.128.128 was the IP address of the PC running XBMC when I tested:

Code:
_MYXBMCADDR = "192.168.128.128"
_MYXBMCPORT = 81

import socket
import select

#create an INET, STREAMing socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#now connect to rattle
s.connect((_MYXBMCADDR, _MYXBMCPORT))

# Send an Introspect command
s.send("POST /jsonrpc HTTP/1.1\x0D\x0A")
s.send("\x0D\x0A")
s.send("{\"jsonrpc\": \"2.0\", \"method\": \"JSONRPC.Introspect\", \"id\": 1}")

# Print the results
while True:
    print s.recv(0x4000)

    if len(select.select([s], [], [], 0)[0]) == 0:
        break;

# Finished
s.shutdown(socket.SHUT_RDWR)
s.close()

To use JSON directly i.e. not via the web server:

Code:
_MYXBMCADDR = "192.168.128.128"
_MYXBMCPORT = 9090

import socket
import select

#create an INET, STREAMing socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

#now connect to rattle
s.connect((_MYXBMCADDR, _MYXBMCPORT))

# Send an Introspect command
s.send("{\"jsonrpc\": \"2.0\", \"method\": \"JSONRPC.Introspect\", \"id\": 1}")

# Print the results
while True:
    print s.recv(0x4000)

    if len(select.select([s], [], [], 0)[0]) == 0:
        break;

# Finished
s.shutdown(socket.SHUT_RDWR)
s.close()

The two examples send an "Introspect" command, which returns a list of all the supported JSON commands.

JR
Reply
#11
hehe thank you! i will definitely NOT look at it now, but when i have more time for digging into it - looks like i will have to learn quite something here! Big Grin
Reply

Logout Mark Read Team Forum Stats Members Help
How to determine what XBMC is doing?0