Announcement

Collapse
No announcement yet.

How are you guys controlling XBMC Frodo

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How are you guys controlling XBMC Frodo

    Hi Guys,

    How are you guys controlling XBMC Frodo now that the http as been taken out, I came across this this which uses jsonrpc but I can't seem to get it to work.
    Is there anyone out there that as managed to get it to work?

    Any help would be apprecited


    Thanks

    #2
    I'll try and help...

    I have not used XBMC before but I downloaded it earlier today to see how easy it was to control.

    The script below was written from information obtained by postings from other members on this board (thanks MrHappy & Jayman13).

    Copy the script below and call it xbmc.vb. Place in your Homeseer/scripts directory

    Set the IP= value to the IP address of your XMBC server
    Set the Port = value to the port used for your XMBC server
    Set the PlayerID = value to the player ID (normally 0 or 1)

    I had no username or password set in the XMBC webserver settings.

    Call the script via an immediate script command:

    &hs.runex("xbmc.vb","Main","<command>")

    The following commands are available:

    quit
    stop
    playpause
    down
    up
    home
    left
    right
    back
    select
    info
    contextmenu
    30secforward
    30secback
    subtitlenext
    subtitleoff
    subtitleon
    showosd
    setfullscreen
    movieslist
    tvlist

    So to quit XBMC you would use:

    &hs.runex("xbmc.vb","Main","quit")

    I have not tested all commands but they should work.

    PHP Code:
    Sub Main(ByVal ComStr As String)

    Dim IP As String "<XBMC IP Address>"
    Dim port As String "<XBMC Port Number>"
    Dim PlayerID As String "0"
    Dim URLStr As String "http://" IP ":" port "/jsonrpc?request="
    Dim ReplyStr As String ""
    Dim JsonStr As String ""


    Select Case ComStr.ToLower
    Case "quit"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Application.Quit"",""id"":1}"
    Case "stop"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Player.Stop"",""params"":{""playerid"":" PlayerID "},""id"":1}"
    Case "playpause"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Player.PlayPause"",""params"":{""playerid"":" PlayerID "},""id"":1}"
    Case "down"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Down"",""id"":1}"
    Case "up"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Up"",""id"":1}"
    Case "home"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Home"",""id"":1}"
    Case "left"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Left"",""id"":1}"
    Case "right"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Right"",""id"":1}"
    Case "select"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Select"",""id"":1}"
    Case "info"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Info"",""id"":1}"
    Case "contextmenu"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.ContextMenu"",""id"":1}"
    Case "30secforward"
        
    JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.Seek"",""params"":{""playerid"":" PlayerID ",""value"":""smallforward""}}"
    Case "30secback"
        
    JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.Seek"",""params"":{""playerid"":" PlayerID ",""value"":""smallbackward""}}"
    Case "back"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Back"",""id"":1}"
    Case "subtitlenext"
        
    JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""next""}"
    Case "subtitleoff"
        
    JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""off""}}"
    Case "subtitleon"
        
    JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""off""}}"
    Case "showosd"
        
    JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.ShowOSD"",""id"":1}"
    Case "setfullscreen"
        
    JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.SetFullscreen"", ""params"": { ""fullscreen"": ""toggle"" }, ""id"": ""1""}"
    Case "movieslist"
        
    JsonStr="{ ""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""parameters"": [ ""MovieTitles"" ] }, ""id"": 1 }"
    Case "tvlist"
        
    JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""parameters"": [ ""TvShowTitles"" ] }, ""id"": 1 }"
    Case else
        
    hs.writelog("XBMC""Command not recognised")
        exit 
    sub
    End select


    If hs.ping(IP) = 0 Then
        URLStr 
    URLStr JsonStr
        ReplyStr 
    hs.urlaction(URLStr,"GET","","")
        If 
    ReplyStr <> "" Then hs.writelog("XBMC"ReplyStr)
    Else
        
    hs.writelog("XBMC""Cannot Send Command - Host Offline")
    End If

    End Sub 
    Jon

    Comment


      #3
      That looks real good Jon and not as complicated as I thought.
      How can I make this work if my XBMC has a username and password. I think that I had to turn this on to use the iPhone app.

      Comment


        #4
        Originally posted by bernieb View Post
        That looks real good Jon and not as complicated as I thought.
        How can I make this work if my XBMC has a username and password. I think that I had to turn this on to use the iPhone app.
        Now you are trying to make me work!

        OK, here you go:

        Copy the script below and call it xbmc.vb. Place in your Homeseer/scripts directory

        Set the IP= value to the IP address of your XMBC server
        Set the Port = value to the port used for your XMBC server
        Set the PlayerID = value to the player ID (normally 0)

        If you have a password and username set in XBMC, set username= and Password= values. Otherwise leave them empty (i.e. remove my text)

        Call the script via an immediate script command:

        &hs.runex("xbmc.vb","Main","<command>")

        The following commands are available:

        quit
        stop
        playpause
        down
        up
        home
        left
        right
        back
        select
        info
        contextmenu
        30secforward
        30secback
        subtitlenext
        subtitleoff
        subtitleon
        showosd
        setfullscreen
        movieslist
        tvlist
        pvrosd
        updatevideo
        fastforward
        rewind

        So to quit XBMC you would use:

        &hs.runex("xbmc.vb","Main","quit")

        PHP Code:
        Imports System.IO
        Imports System
        .Net
        Imports System
        .Text


        Sub Main
        (ByVal ComStr As String)

        Dim IP As String "<XBMC IP Address>"
        Dim port As String "<XBMC Port Number>"
        Dim Username As String "<XBMC Username>"
        Dim Password As String "<XBMC Password>"
        Dim PlayerID As String "0"
        Dim URLStr As String "http://" IP ":" port "/jsonrpc"
        Dim ReplyStr As String ""
        Dim JsonStr As String ""

        Try
            
            
        Select Case ComStr.ToLower
            
        Case "quit"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Application.Quit"",""id"":1}"
            
        Case "stop"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Player.Stop"",""params"":{""playerid"":" PlayerID "},""id"":1}"
            
        Case "playpause"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Player.PlayPause"",""params"":{""playerid"":" PlayerID "},""id"":1}"
            
        Case "down"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Down"",""id"":1}"
            
        Case "up"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Up"",""id"":1}"
            
        Case "home"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Home"",""id"":1}"
            
        Case "left"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Left"",""id"":1}"
            
        Case "right"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Right"",""id"":1}"
            
        Case "select"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Select"",""id"":1}"
            
        Case "info"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Info"",""id"":1}"
            
        Case "contextmenu"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.ContextMenu"",""id"":1}"
            
        Case "30secforward"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.Seek"",""params"":{""playerid"":" PlayerID ",""value"":""smallforward""}}"
            
        Case "30secback"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.Seek"",""params"":{""playerid"":" PlayerID ",""value"":""smallbackward""}}"
            
        Case "back"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.Back"",""id"":1}"
            
        Case "subtitlenext"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""next""}"
            
        Case "subtitleoff"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""off""}}"
            
        Case "subtitleon"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSubtitle"",""params"":{""playerid"":" PlayerID ",""subtitle"":""off""}}"
            
        Case "showosd"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""Input.ShowOSD"",""id"":1}"
            
        Case "setfullscreen"
                
        JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.SetFullscreen"", ""params"": { ""fullscreen"": ""toggle"" }, ""id"": ""1""}"
            
        Case "movieslist"
                
        JsonStr="{ ""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""parameters"": [ ""MovieTitles"" ] }, ""id"": 1 }"
            
        Case "tvlist"
                
        JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""parameters"": [ ""TvShowTitles"" ] }, ""id"": 1 }"
            
        Case "pvrosd"
                
        JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""pvrosdchannels""}, ""id"": 1 }"
            
        Case "updatevideo"
                
        JsonStr="{""jsonrpc"":""2.0"",""method"":""VideoLibrary.Scan"",""id"":1}"
            
        Case "fastforward"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSpeed"",""params"":{""playerid"":" PlayerID ",""speed"":""increment""}}"
            
        Case "rewind"
                
        JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSpeed"",""params"":{""playerid"":" PlayerID ",""speed"":""decrement""}}"
            
        Case else
                
        hs.writelog("XBMC""Command not recognised")
                exit 
        sub
            End select
        Catch ex As Exception
            hs
        .writelog("XBMC""Error in code block 1: " ex.ToString)
        End try

        Try
            If 
        hs.ping(IP) = 0 Then
                Dim httpWebRequest 
        As HttpWebRequest DirectCast(WebRequest.Create(URLstr), HttpWebRequest)
                
        Dim networkCredential As New NetworkCredential(UsernamePassword)
                
        httpWebRequest.Credentials networkCredential
                httpWebRequest
        .ContentType "application/json"
                
        httpWebRequest.Method "POST"
                
        Using streamWriter As New StreamWriter(httpWebRequest.GetRequestStream())
                    
        streamWriter.Write(Jsonstr)
                
        End Using
            
                Dim httpResponse 
        As HttpWebResponse DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
                
        Using streamReader As New StreamReader(httpResponse.GetResponseStream())
                    
        ReplyStr streamReader.ReadToEnd()
                    If 
        ReplyStr <> "" Then hs.writelog("XBMC"ReplyStr)
                
        End Using
            
        Else
                
        hs.writelog("XBMC""Cannot Send Command - Host Offline")
            
        End If
        Catch 
        ex As Exception
            hs
        .writelog("XBMC""Error in code block 2: " ex.ToString)
        End try

        End Sub 
        Last edited by jon00; March 30, 2013, 07:12 AM.
        Jon

        Comment


          #5
          I appreciate the effort Jon ... thanks, I'll try this out over the weekend

          Comment


            #6
            Please let me know how you got on!
            Jon

            Comment


              #7
              Hi Jon00,

              Thanks for your help very much appreciated, will try them later a post back

              Comment


                #8
                Hi Jon.
                I just tried the script ( the one without password) But i get an error

                Code:
                29.03.2013 22:17:46  - Event - Running script statement immediately: &hs.runex("xbmcStue.vb","Main","stop")
                
                29.03.2013 22:17:46  - XBMC - {"error":{"code":-32100,"message":"Failed to execute method."},"id":1,"jsonrpc":"2.0"}
                I use the latest version of XBMC called frodo.

                Edit: My fault! Had to set player id to 1 - as you said in the intro....

                Thank you for this nice script.
                I mostly use the PVR feature in XBMC as the box from my cable company is not any good. I tried to search xmbc for a hint for opening the PVR/EPG window, but i could not figure it out.
                i guess it must be a GUI.ActivateWindow thing, so my thought was to modyfy the tvlist function and add it to the "case select statement, but do you know where i can find a list of the parameters like "video" and "TvShowTitles" that GUI.ActivateWindow accepts?
                Hope that made sense, as i am so not a programmer..

                Thanks
                Last edited by markus.bergvoll; March 29, 2013, 04:55 PM.

                Comment


                  #9
                  You can try:

                  PHP Code:
                  Case "pvrosd"
                  JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""GUI.ActivateWindow"", ""params"": { ""window"": ""video"", ""pvrosdchannels""}, ""id"": 1 }" 
                  Jon

                  Comment


                    #10
                    Hi jon00,

                    well the playpause and the stop work perfectly, not had chance to try the others but can't see why they wouldn't work as well, are there any other command other than those in your list would like a command to update my movies and possible some other thing that are not in your list,

                    Thought I had seen a list in my search but can't seem to find it now.

                    Thanks again for your help it's really appreciated I can now get my HStouch remote working again

                    Comment


                      #11
                      If people come up with new commands that work, I'll happily add it to the script for others to use.

                      It may be best for all to use the second script I posted (just leave username and password blank if you do not set this in XBMC) and we can build on that one.
                      Jon

                      Comment


                        #12
                        Hi Guys,

                        Ok for anyone that is interested a few more commands (work in progress)

                        had these to the xbmc.vb script

                        For video database scan tested working

                        Code:
                        Case "updatevideo"
                            JsonStr="{""jsonrpc"":""2.0"",""method"":""VideoLibrary.Scan"",""id"":1}"
                        For increment fast forward tested working

                        Code:
                        Case "fastforward"
                            JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSpeed"",""params"":{""playerid"":1,""speed"":""increment""}}"
                        For incremental rewind tested working

                        Code:
                        Case "rewind"
                            JsonStr="{""jsonrpc"":""2.0"",""id"":1,""method"":""Player.SetSpeed"",""params"":{""playerid"":1,""speed"":""decrement""}}"
                        For scrolling through the audio tracks of the playing video tested working

                        Code:
                        Case "nextaudio"
                            JsonStr="{""jsonrpc"": ""2.0"", ""method"": ""Player.SetAudioStream"", ""params"": { ""playerid"": 1, ""stream"": ""next""}, ""id"": 1}"



                        Once again thanks jon00


                        .
                        Last edited by S.Morris; April 4, 2013, 05:18 PM.

                        Comment


                          #13
                          Thanks,

                          I've now updated the second script with this info: http://board.homeseer.com/showpost.p...41&postcount=4
                          Jon

                          Comment


                            #14
                            Hi jon00,

                            wondering if you could help again, found this list of commands and the one i tried "audionextlanguage" I couldn't get it to working, but it's no surprise being as I don't know what I am doing

                            Code:
                            {
                              "enums": [
                                "left", 
                                "right", 
                                "up", 
                                "down", 
                                "pageup", 
                                "pagedown", 
                                "select", 
                                "highlight", 
                                "parentdir", 
                                "parentfolder", 
                                "back", 
                                "previousmenu", 
                                "info", 
                                "pause", 
                                "stop", 
                                "skipnext", 
                                "skipprevious", 
                                "fullscreen", 
                                "aspectratio", 
                                "stepforward", 
                                "stepback", 
                                "bigstepforward", 
                                "bigstepback", 
                                "osd", 
                                "showsubtitles", 
                                "nextsubtitle", 
                                "codecinfo", 
                                "nextpicture", 
                                "previouspicture", 
                                "zoomout", 
                                "zoomin", 
                                "playlist", 
                                "queue", 
                                "zoomnormal", 
                                "zoomlevel1", 
                                "zoomlevel2", 
                                "zoomlevel3", 
                                "zoomlevel4", 
                                "zoomlevel5", 
                                "zoomlevel6", 
                                "zoomlevel7", 
                                "zoomlevel8", 
                                "zoomlevel9", 
                                "nextcalibration", 
                                "resetcalibration", 
                                "analogmove", 
                                "rotate", 
                                "rotateccw", 
                                "close", 
                                "subtitledelayminus", 
                                "subtitledelay", 
                                "subtitledelayplus", 
                                "audiodelayminus", 
                                "audiodelay", 
                                "audiodelayplus", 
                                "subtitleshiftup", 
                                "subtitleshiftdown", 
                                "subtitlealign", 
                                "audionextlanguage", 
                                "verticalshiftup", 
                                "verticalshiftdown", 
                                "nextresolution", 
                                "audiotoggledigital", 
                                "number0", 
                                "number1", 
                                "number2", 
                                "number3", 
                                "number4", 
                                "number5", 
                                "number6", 
                                "number7", 
                                "number8", 
                                "number9", 
                                "osdleft", 
                                "osdright", 
                                "osdup", 
                                "osddown", 
                                "osdselect", 
                                "osdvalueplus", 
                                "osdvalueminus", 
                                "smallstepback", 
                                "fastforward", 
                                "rewind", 
                                "play", 
                                "playpause", 
                                "delete", 
                                "copy", 
                                "move", 
                                "mplayerosd", 
                                "hidesubmenu", 
                                "screenshot", 
                                "rename", 
                                "togglewatched", 
                                "scanitem", 
                                "reloadkeymaps", 
                                "volumeup", 
                                "volumedown", 
                                "mute", 
                                "backspace", 
                                "scrollup", 
                                "scrolldown", 
                                "analogfastforward", 
                                "analogrewind", 
                                "moveitemup", 
                                "moveitemdown", 
                                "contextmenu", 
                                "shift", 
                                "symbols", 
                                "cursorleft", 
                                "cursorright", 
                                "showtime", 
                                "analogseekforward", 
                                "analogseekback", 
                                "showpreset", 
                                "presetlist", 
                                "nextpreset", 
                                "previouspreset", 
                                "lockpreset", 
                                "randompreset", 
                                "increasevisrating", 
                                "decreasevisrating", 
                                "showvideomenu", 
                                "enter", 
                                "increaserating", 
                                "decreaserating", 
                                "togglefullscreen", 
                                "nextscene", 
                                "previousscene", 
                                "nextletter", 
                                "prevletter", 
                                "jumpsms2", 
                                "jumpsms3", 
                                "jumpsms4", 
                                "jumpsms5", 
                                "jumpsms6", 
                                "jumpsms7", 
                                "jumpsms8", 
                                "jumpsms9", 
                                "filter", 
                                "filterclear", 
                                "filtersms2", 
                                "filtersms3", 
                                "filtersms4", 
                                "filtersms5", 
                                "filtersms6", 
                                "filtersms7", 
                                "filtersms8", 
                                "filtersms9", 
                                "firstpage", 
                                "lastpage", 
                                "guiprofile", 
                                "red", 
                                "green", 
                                "yellow", 
                                "blue", 
                                "increasepar", 
                                "decreasepar", 
                                "volampup", 
                                "volampdown", 
                                "channelup", 
                                "channeldown", 
                                "previouschannelgroup", 
                                "nextchannelgroup", 
                                "leftclick", 
                                "rightclick", 
                                "middleclick", 
                                "doubleclick", 
                                "wheelup", 
                                "wheeldown", 
                                "mousedrag", 
                                "mousemove", 
                                "noop"
                              ], 
                              "id": "Input.Action", 
                              "type": "string", 
                              "default": "left"

                            Comment


                              #15
                              I could not find audionextlanguage in the api
                              Jon

                              Comment

                              Working...
                              X