Keeping the screen on

  1. 8 years ago

    There must be an option (if there is, I can't find it...) to keep the screen on. A book is usually read aloud by a narrator, the kids listen and might not touch the screen for a while. Then, suddenly, the screen turns off, and when awaken (by one of the parents...), the page reloads and narrations starts over from the beginning. This is a big issue, in my eyes.
    If there's a way around that, please advise.

  2. Angelo S

    13 Jan 2016 Administrator

    Hi Ran,
    We will investigate further on implementing a feature to let the author decide the minimum delay for the screen to turn off. Never letting the screen turn off is not generally a good idea, and also some of our users use PubCoder to create things that are more apps than books, so we want to implement tuneable preference instead of a fixed behavior.
    Keep in mind that we still have to verify if this is technically possible on both iOS and Android. As for the EPUB3 or HTML output, that behavior depends on the reader/browser of choice.

    Best Regards,
    Angelo

  3. Sure, that's what I meant.
    BTW, I found a way to do it in Java, but not Javascript:
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    Many games do keep the screen on at all times. see Candy Crash for example. Obviously, it consumes a lot of power, but at least for a self-reading book it makes sense (to me).

  4. 6 months ago

    Hi,
    Fast forward 8 years. Is there now an option I can use for that?
    If not, can you suggest JS code that will work for both iOS and Android?
    I tried this (only on Android), but it didn't do the trick:

    async function preventScreenTimeout() {
    try {
    if ('wakeLock' in navigator) {
    const wakeLock = await navigator.wakeLock.request('screen');
    console.log('Screen Wake Lock is active');
    return wakeLock;
    }
    } catch (err) {
    }
    }

    // To release the wake lock when no longer needed
    async function releaseScreenTimeout(wakeLock) {
    if (wakeLock) {
    await wakeLock.release();
    console.log('Screen Wake Lock is released');
    }
    }

    // Example usage
    let wakeLock = null;

    document.addEventListener('visibilitychange', async () => {
    if (document.visibilityState === 'visible') {
    wakeLock = await preventScreenTimeout();
    } else {
    await releaseScreenTimeout(wakeLock);
    }
    });

  5. Angelo S

    27 May 2024 Administrator

    When exporting a native app, or using Shelf or PubReader, the device should not sleep already when reading a book. Don't know about a universal way to do it in other formats

  6. What do you mean by "native app"? I've exported to Android for testing, via Wi-Fi, and the screen turns off per my phone's settings (after 30sec). What am I missing?

  7. Angelo S

    30 May 2024 Administrator

    Hello Ran, we're investigating the issue, it shouldn't go to sleep but it seems at the moment there is an issue with iOS app and Android app exports, while device properly doesn't go to sleep when viewing the content on PubReader and Shelf.
    Will be back soon with a beta that fixes the issue.

  8. Ok, thanks. Let me know when, and I'll do the testing.

  9. 5 months ago

    Hi, any update on this matter? that's the only thing standing between my app and the app stores ...
    BTW, I've noticed 2 things:
    First, even with PubReader, the screen dims after the set screen timeout. Still, it doesn't turn the screen off and stops reading, as in the native app.
    Second, if I turn on (in Android, not sure about iOS) Settings --> Advanced --> Motions and gestures --> Keep screen while viewing, the problem is solved. Perhaps that could be done automatically be the app (even if you'll need to ask the user's permissions)?

  10. Angelo S

    5 Jun 2024 Administrator

    Hello Ran, we nearly fixed the issue and will release a beta tomorrow

  11. Angelo S

    6 Jun 2024 Administrator

    Hello Ran, here's the beta of PubCoder 5.0.7, which should fix the issue: https://www.dropbox.com/scl/fi/dgkvzzkrftsshfwr52brl/PubCoder-bin-20240606-5.0.7.1254.zip?rlkey=waqvpjwhge6443onk9ck91mid&dl=0

    Please let me know if it works for you.

  12. Perfect, thanks. It seems to work, not even dimming (at least on my Android phone)!
    I'll do the testing on iPhone next week.
    Thanks again for the quick resolution
    Ranco

 

or Sign Up to reply!