![]() |
#1 |
Member
![]() Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
JavaScript problem: mirror my phone's screen in browser
I am trying to build an app to mirror my phone's screen in the ebook's browser.
The problem I am running in with my kobo and kindle that the browsers don't support websockets. I have also tryed to update the image via setInterval, but it's not working. I am running out of ideas how I can do it. Is there a spec of Kobo/Kindle's browser Javascript Dom API somewhere? Any ideas how to browser debugging? Other methods to show an updated picture on KOBO/Kindle? |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,785
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
|
![]() |
![]() |
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 868
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
If you want to stick with JavaScript, server sent events could potentially be used, as I know the Kobo browser supports that. Whether you send the image directly to the Kobo by base64 encoding it, or sending update info for the Kobo to fetch an image from a URL is up to you.
|
![]() |
![]() |
![]() |
#4 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,492
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
The Kobo is probably going to have an *extremely* hard time dealing with anything image-related on its own at anything better than a snails pace, especially given the native resolution on the average midrange smartphone.
If you go this route, better have the source preprocess the image as much as possible, so that the Kobo ends up having to do almost zero work besides dumping that to the framebuffer verbatim (i.e., match the target pixel format, ideally after having switched to 8bpp on the Kobo to save some bandwidth). (The examples in the Python FBInk bindings have some musings about that sort of things). Last edited by NiLuJe; 05-23-2020 at 01:11 AM. |
![]() |
![]() |
![]() |
#5 | |
Member
![]() Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
Quote:
My last workaround Idea was to use setInterval to trigger an update of an img element with webser serving the latest image at a url. Unfortunately setInterval doesn't seem to work |
|
![]() |
![]() |
![]() |
#6 | |
Member
![]() Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
Quote:
I will check out FBInk, do you have more recommendations for an optimal image format - 8bpp is already something I don't understand. Do you think it's possible to fetch and show images with FBInk? What would be an easy proof of concept? |
|
![]() |
![]() |
![]() |
#7 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 868
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
TLDR, it's super easy to setup, assuming you don't need bi-directional communications. Although, if needed, you could set up your own return channel if required. I know the Kobo browser supports it, because I've used it. |
|
![]() |
![]() |
![]() |
#8 |
Member
![]() Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
thanks! Looks like a great option!
|
![]() |
![]() |
![]() |
#9 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,492
Karma: 26047188
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
I was talking about the 'DIY' approach, i.e., stream raw image data in the proper pixel format.
For the browser approach, you probably actually *don't* want to do that, because Nickel runs @ 32bpp, so you'll probably want to send images encoded in a format that decodes to RGBA to avoid an extra Y8 <-> RGBA roundtrip on Qt's side on the device. (The extra bandwidth needed by RGBA over Y8 is *usually* still faster than the extra processing power needed by the grayscale expansion to RGBA, but YMMV. Overhead is in a different place in each case, but it's still there one way or the other. Have to DIY to get rid of any overhead on that front ![]() Last edited by NiLuJe; 05-23-2020 at 12:05 PM. |
![]() |
![]() |
![]() |
#10 | |
Member
![]() Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
Quote:
Edit: nevermind, it works - I was just having es6 syntax in my js Last edited by jefferson; 05-25-2020 at 09:22 AM. |
|
![]() |
![]() |
![]() |
#11 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 868
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Quote:
I've used the event field myself. Something like the following worked for me: Code:
var evtSource = new EventSource("/messages"); evtSource.addEventListener("body", function (event) { // code goes here }); |
|
![]() |
![]() |
![]() |
Tags |
browser, browser restrictions, javascript |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
JavaScript debugging in mobile browser and WAF | jnjitkoff | Kindle Developer's Corner | 4 | 03-13-2019 03:46 AM |
Beta-Browser JavaScript debugging | clausmuus | Kindle Developer's Corner | 0 | 09-28-2016 06:37 AM |
Kindle touch browser javascript capabilities | iPocketBook | Kindle Developer's Corner | 14 | 01-03-2013 09:10 AM |
Javascript support in PB302 browser ? | aruangra | PocketBook | 8 | 05-25-2010 07:11 PM |
iLiad Is there an Iliad browser that supports javascript? | Maike13 | iRex Developer's Corner | 0 | 12-09-2009 01:56 PM |