Keeping a Vega app on screen for signage and dashboards: a working stopgap until there's an API

This keeps coming up (#27955, #28610, #28808, #29246 and #29794), and most of those threads are closed now, so here’s what I know in one place for anyone running signage, dashboards or kiosks on Vega.

The problem. After 5 minutes without a key press, Vega starts the screensaver over whatever is in the foreground. There’s no keep-awake API, no manifest privilege for it and no expo-keep-awake port.

Why. The resource manager only holds the display for an app with an audio-playback or video-playback session. You can see it in the device log: app's active session ... is not one of the display session(s). A <video> or <audio> inside a WebView doesn’t help, because it only registers the generic media-playback session.

What works for me. Play something. I loop a tiny silent MP3 through the native AudioPlayer while the app is in the foreground and pause it in the background, so the screensaver still behaves normally everywhere else.

import { useEffect } from "react";
import { AppState, Image } from "react-native";
import { AudioPlayer } from "@amazon-devices/react-native-w3cmedia";

const SILENCE = require("./silence.mp3"); // a few minutes of silent 8 kbps mono MP3

export function useKeepAwake() {
  useEffect(() => {
    let player: AudioPlayer | null = null;
    let disposed = false;
    const sync = (state: string) => (state === "active" ? player?.play().catch(() => {}) : player?.pause());

    // start a few seconds after launch so it doesn't compete with the first render
    const start = setTimeout(async () => {
      const p = new AudioPlayer();
      await p.initialize();
      p.loop = true;
      p.src = Image.resolveAssetSource(SILENCE).uri.replace(/^file:\/\//, ""); // plain path, not file://
      if (disposed) return p.deinitialize();
      player = p;
      sync(AppState.currentState);
    }, 5000);

    const sub = AppState.addEventListener("change", sync);
    return () => {
      disposed = true;
      clearTimeout(start);
      sub.remove();
      player?.pause();
      player?.deinitialize().catch(() => {});
    };
  }, []);
}

And in manifest.toml, the media services go in [wants] (the build adds the modules to [needs] by itself):

[[wants.service]]
id = "com.amazon.mediametrics.service"
[[wants.service]]
id = "com.amazon.mediabuffer.service"
[[wants.service]]
id = "com.amazon.mediatransform.service"
[[wants.service]]
id = "com.amazon.audio.stream"
[[wants.service]]
id = "com.amazon.audio.control"
[[wants.service]]
id = "com.amazon.media.server"
[[wants.service]]
id = "com.amazon.media.playersession.service"

Gotchas

  • strip file:// from the bundled asset’s URI, or the player won’t load it
  • the silent player takes media-control focus, so “Alexa, play/resume” does nothing (it thinks it’s already playing). Next/Previous can still be handled through it
  • if your app is mostly a WebView, run the player in the React Native component that hosts it. The page itself doesn’t need to change (I haven’t tested a WebView app myself, so treat that part as a hint)

Honest limits. I’ve only tested this on a Fire TV Stick HD with Vega OS 2.0, not the 4K Select. On that stick my app also stops by itself about 33 minutes after launch, with no crash report, and I don’t know yet whether that’s related. So please check a long run on your own hardware before you rely on this for an all-day screen, and if you’ve seen the same thing, I’d love to hear it here.

It’s a workaround, not an API. The original feature request is #27955: Feature Request: API to disable screensaver for signage apps. If you need this for a product, a short note on your use case in Feature Requests probably helps more than anything.

Longer write-up with the full code: Keeping a Fire TV awake: how a live photo wall holds off the Vega OS screensaver · BoothWall blog

P.S. If anyone at Amazon has a spare newer Fire TV or Vega device lying around, I’d happily give it a proper workout :grinning_face_with_smiling_eyes:

Hi @ddedic,

Thank you for taking the time to bring this together in one place and share what has worked for you with the community.

Vega OS does not currently provide an API or manifest privilege that lets an app keep the display awake or disable the screensaver. Please note that the approach above is a community-shared workaround and not an officially supported mechanism. We’ve captured the request for a keep-awake capability for signage and dashboard use cases and shared it with our team [API or flag to prevent sleep mode].

Thanks for helping us improve the Vega platform.

Warm regards,
Aishwarya

Thanks Aishwarya, really appreciate you passing it on to the team. Good to have it confirmed there’s no official way yet, so at least I know I’m not missing something obvious in the docs.

I’ll keep the silent track running for now since it works fine in practice, and switch over as soon as there’s a proper flag. If you need someone to test it when it lands, happy to help.