05-22-2020, 06:06 PM | #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? |
05-22-2020, 06:22 PM | #2 |
Wizard
Posts: 2,798
Karma: 6990707
Join Date: May 2016
Location: Ontario, Canada
Device: Kobo Mini, Aura Edition 2 v1, Clara HD
|
|
Advert | |
|
05-22-2020, 06:30 PM | #3 |
Guru
Posts: 873
Karma: 2676800
Join Date: Sep 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.
|
05-23-2020, 02:08 AM | #4 |
BLAM!
Posts: 13,499
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 02:11 AM. |
05-23-2020, 04:26 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 |
|
Advert | |
|
05-23-2020, 04:33 AM | #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? |
|
05-23-2020, 04:48 AM | #7 | |
Guru
Posts: 873
Karma: 2676800
Join Date: Sep 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. |
|
05-23-2020, 08:10 AM | #8 |
Member
Posts: 21
Karma: 10
Join Date: May 2014
Device: kindle
|
thanks! Looks like a great option!
|
05-23-2020, 01:01 PM | #9 |
BLAM!
Posts: 13,499
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 01:05 PM. |
05-25-2020, 09:26 AM | #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 10:22 AM. |
|
05-25-2020, 09:42 AM | #11 | |
Guru
Posts: 873
Karma: 2676800
Join Date: Sep 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 |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
JavaScript debugging in mobile browser and WAF | jnjitkoff | Kindle Developer's Corner | 4 | 03-13-2019 04:46 AM |
Beta-Browser JavaScript debugging | clausmuus | Kindle Developer's Corner | 0 | 09-28-2016 07:37 AM |
Kindle touch browser javascript capabilities | iPocketBook | Kindle Developer's Corner | 14 | 01-03-2013 10:10 AM |
Javascript support in PB302 browser ? | aruangra | PocketBook | 8 | 05-25-2010 08:11 PM |
iLiad Is there an Iliad browser that supports javascript? | Maike13 | iRex Developer's Corner | 0 | 12-09-2009 02:56 PM |