Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Previous page Next page Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Page 2 of 3
Topic:
Working on KODI feedback
This thread has 41 replies. Displaying posts 16 through 30.
OP | Post 16 made on Sunday August 2, 2020 at 14:17
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
On August 2, 2020 at 12:30, Lyndel McGee said...
Do google search for jsonrpc 2 batch. Not sure if KODI supports it yet but you send an array of requests and get back an array of responses.

I believe these commands are already batch request. the issue is one is a "Player.GetProperties" and the other is a "Player.GetItem". You can make the ID what ever you wish, just trying to see if it can be sent from a single command or what may be an alternative in JavaScript, so send tow different request in one script. I also have asked on the KODI forums but so far no reply.
Post 17 made on Sunday August 2, 2020 at 14:53
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
If the command text you are sending does not start with '[' and end with ']', they are not an array.

[Link: jsonrpc.org]

It may be that KODI does not yet support this feature as I see your URL has request={some json body for single request}. If this is indeed the case, you will be faced with sending multiple HTTP requests and processing responses asynchronously to get a User interface that flows well and is considerate of socket resources.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 18 made on Sunday August 2, 2020 at 17:25
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
So far I got it working, just not sure on the efficacy. Right now the remote is pinging KODI every 3 seconds. Good thing about KODI is it handles that very well. Been doing that for years from DemoPad with out any issues. So far the remote handles it nicely. I am not pulling a tun of data over so it seems to be fast. I know at some point I want to make it so that the remote makes the socket connection when I load the page and keeps it open till I leave the page. Not sure if that's a good idea or not. For now I want to get a progress slider up and running. Pretty basic so far.

Thanks for your help.
Post 19 made on Sunday August 2, 2020 at 18:05
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
The only way to keep socket open is to use http 1.1 protocol and supply a connection:keep-alive request header. The lifetime will depend on the server. In the case of logitech media center, it closes the socket after 75 secs of inactivity. If you want to do this, you will need to process the content length response headers so that you can send multiple http request/response pairs across the same socket. This is known as request pipelining.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 20 made on Sunday August 2, 2020 at 18:28
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
On August 2, 2020 at 18:05, Lyndel McGee said...
The only way to keep socket open is to use http 1.1 protocol and supply a connection:keep-alive request header. The lifetime will depend on the server. In the case of logitech media center, it closes the socket after 75 secs of inactivity. If you want to do this, you will need to process the content length response headers so that you can send multiple http request/response pairs across the same socket. This is known as request pipelining.

OK, Thanks

Before I dig to far into this, is it possible to have a workable slider, one where you can grab and drag the slider with your finger?
Post 21 made on Sunday August 2, 2020 at 18:52
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
Have a look at the dev guide and the onMove event?

I DO NOT recommend this approach for volume control. Too risky to blow speakers.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 22 made on Sunday August 2, 2020 at 19:45
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
Ya, I'm Kinda wondering how well they work. With such an old touch screen, I am thinking of overlaying transparent buttons to jump to that percentage. Then I just touch the bar to about where I wish to jump too
Post 23 made on Sunday August 2, 2020 at 20:58
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
That will be your best approach but beware that you can easily blow your speakers especially if all your music is not at the same level or all the inputs on your receiver are not leveled the same.

It is also very easy to have your receiver muted and then think that the volume is too low and press the right-most button at which time your receiver comes off mute and you risk blowing out both your eardrums and your speakers.

Take it from me as I have developed multiple TCP/IP versions of a Denon/Marantz module and have experienced this first-hand, especially with the Denon/Marantz Ipad app. :-(

I always use volume ramping and if volume is <-20db, I can ramp +2db at a time but anything above that ramps at only 1db moving up. Of course, going down is not an issue and I can jump -2db without any issues.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 24 made on Wednesday August 5, 2020 at 15:37
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
Sp got every thing working but cover art, I am using the script from developers guide

var cover = info1.split('"thumbnail":"image://').pop().split('/')[0];
// remove the HTTP information from the received data
var imageStartIndex = cover.indexOf("\r\n\r\n");
var bitmapData = cover.substring(imageStartIndex);
// make and display the image
var MyImage = new Image(bitmapData+4);
widget(“MOVIE_COVER”).setImage(MyImage);

The Var Cover = looks like this from the KODI player,

http%3a%2f%2fimage.tmdb.org%2ft%2fp%2foriginal%2f579HAFLpODEC9Reb64wbCHSUi4O.jpg

the sample script does not work and locks up all the other scripts that pulls data

I am not using the HttpLibrary. I do not understand the sample in the developers guide on how to assign and display that to a panel.
Post 25 made on Wednesday August 5, 2020 at 17:51
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
Note that I have added left/right brackets added around http preamble to prevent RC from trying to download the actual URLs :-).

Example 11.3 in the Dev Guide assumes that the image url is:

[http://]MyServer.com/images/img1.jpg

You can take the URL data you get from KODI (example you posted) and then all decodeURI(urlText) to get the URL that you need to request in human-readable terms.

[Link: w3schools.com]


Next, you need to do an HTTP Get Request to

[http://]image.tmdb.org/t/p/original/579HAFLpODEC9Reb64wbCHSUi4O.jpg

You do this in the same way you submit 'GET' requests to KODI...

Instead of a socket IP address, you pass in 'image.tmdb.org' for the host/ip and the port number is 80 to your socket constructor.

The actual line you use to request the image is the path part of the URL which starts after the first '/' following the host.

In this case your string would be:

'GET /t/p/original/579HAFLpODEC9Reb64wbCHSUi4O.jpg /HTTP1.0\r\n\r\n'

The actual response payload (imageStartIndex) indicates the position of the delimiter of the HTTP Response Header and body. In order to take the response data you have to move past the '\r\n\r\n' to get to the start of the image data which is imageStartIndex + 4.

The example you supplied is erroneously trying to create an image with a string that starts with '\r\n\r\n' and has the number '4' appended to the end. (adding integer 4 to a string results in concatenating '4'). As the string does not start with 'JPEG' or whatever the preamble for the actual image data is but insteads starts with '\r\n\r\n', that's the cause of your issue.

Make this change along with decoding the URI as I called out above and I think you'll see different results that actually work.


// remove the HTTP information from the received data
var imageStartIndex = cover.indexOf("\r\n\r\n");
var bitmapData = cover.substring(imageStartIndex+4);
// make and display the image
var MyImage = new Image(bitmapData);
widget(“MOVIE_COVER”).setImage(MyImage);

Last edited by Lyndel McGee on August 5, 2020 18:12.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 26 made on Wednesday August 5, 2020 at 18:33
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
OK, I think I may have an understanding. So the question is where would I put this, for I am amusing I can not open and close two sockets and write to two sockets all in the same function.

so this is my script so far,

var url = CF.widget("Kodi_aURL","Kodi_PARAMETERS_test").label;
var info;
var FFcommand = "2";
var RRcommand = "2";
function kodi1(){
var socket = new TCPSocket();
socket.onConnect = function() {
prefix = 'GET /jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetItem", "params": { "properties": ["title", "thumbnail"], "playerid": 1 }, "id": "1"}'
postfix = ' HTTP/1.0\r\n'
try {
socket.write(prefix+postfix);
socket.write("HOST:+url+\r\n\r\n");
} catch(e) {
socket.close()
}}
socket.onData = function() {
info1 = socket.read();
if (info1.indexOf('unknown') !== -1) {
CF.widget("KODI_TITLE").label="Nothing Playing";
}else{
var title = info1.split('title":"').pop().split('","type')[0];
CF.widget("KODI_TITLE").label=title;
}
socket.close()
}
socket.onIOError = function(e) {
socket.close()
}
socket.connect(url, 9090, 3000);
};

Last edited by mpg7321 on August 5, 2020 19:06.
Post 27 made on Thursday August 6, 2020 at 12:09
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
Use scheduleAfter to call a 2nd function after getting reply from kodi with the url

in the function you assigned to socket.onClose, do the following:


socket.onClose = function() {
CF.activity().scheduleAfter(100,myNextFunctionThatNeedsToBeCalled);
}

Dev Guide should have an example showing how to do this.

Last edited by Lyndel McGee on August 6, 2020 13:45.
Lyndel McGee
Philips Pronto Addict/Beta Tester
Post 28 made on Thursday August 6, 2020 at 13:47
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
On August 5, 2020 at 18:33, mpg7321 said...
OK, I think I may have an understanding. So the question is where would I put this, for I am amusing I can not open and close two sockets and write to two sockets all in the same function.

You can have up to 16 sockets open concurrently. Within the same function is also possible "if" you name the variable differently.

var socket1 = new TCPSocket();
var socket2 = new TCPSocket();

socket1.onData = function() {
}
socket2.onData = function() {
}

I had previously referenced the Dev Guide and a O'Reilly Javascript 5th Edition book by David Flanagan (specifically the first 10 chapters). Have you had an opportunity to review the last 1?
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 29 made on Thursday August 6, 2020 at 14:33
mpg7321
Regular Member
Joined:
Posts:
June 2020
51
Am I'm just dumb or some thing? Still locks up all script. So in the previous script I am parsing out and assigning to the "var cover" to equal "579HAFLpODEC9Reb64wbCHSUi4O" Then wrote the following script.

var url1 = "image.tmdb.org";
function kodi2(){
var socket = new TCPSocket();
socket.onConnect = function() {
prefix = 'GET /t/p/original/'
postfix = '.jpg /HTTP1.0\r\n\r\n'
try {
socket.write(prefix+cover+postfix);
socket.write("HOST:+url1+\r\n\r\n");
} catch(e) {
socket.close()
}}
socket.onData = function() {
var cover1 = socket.read();
// remove the HTTP information from the received data
var imageStartIndex = cover1.indexOf("\r\n\r\n");
var bitmapData = cover1.substring(imageStartIndex+4);
// make and display the image
var MyImage = new Image(bitmapData);
CF.widget(“MOVIE_COVER”).setImage(MyImage);
socket.close()
}
socket.onIOError = function(e) {
socket.close()
}
socket.connect(url1, 80, 3000);
scheduleAfter(500,kodi3);
};

Not sure if this mattered but tried both
CF.widget(“MOVIE_COVER”).setImage(MyImage);
widget(“MOVIE_COVER”).setImage(MyImage);

Last edited by mpg7321 on August 6, 2020 14:40.
Post 30 made on Thursday August 6, 2020 at 16:12
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
12,554
Did you try GUI.widget?
Lyndel McGee
Philips Pronto Addict/Beta Tester
Page 2 of 3


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse