My 1.17 MB player now listens to the battery: thermal-aware decode + a metered-data mode - DEV Community

DEV Community

hammi
hammi

Posted on

My 1.17 MB player now listens to the battery: thermal-aware decode + a metered-data mode

i've been building a small 4K media player client for Android + Windows (RKMovies), and two complaints kept showing up in my own testing: on budget phones, long 4K sessions make the back of the phone uncomfortably warm, and on metered connections the player can chew through a daily data quota. both felt like "just use the hardware decoder" problems at first. they weren't.

the thermal part

the obvious move is a hardware-accelerated MediaCodec, and that was already in. the surprise was how fast even hardware decode heats a mid-tier chip when the phone is already warm (charging while playing, or a hot room). numbers i found while researching this: hardware HEVC/AV1 decode draws roughly 0.8-1.3 W, while software VP9 on the same phone draws 3.2-4.5 W and thermally throttles in under two minutes. so the lever isn't only which decoder you pick, it's reacting to the phone's thermal state.

so the player now registers a PowerManager thermal status listener while playback is active (API 29+, no polling, nothing runs in the background). on THERMAL_STATUS_MODERATE it drops one rung on the decode profile, and below 20% battery it caps the bitrate ceiling. when playback stops, the listener is removed. cost in the APK: basically zero. the app is still 1.17 MB total.

one more trap i hit: MediaCodecInfo claims a codec is supported, but some SoCs silently fall back to software decode. so at session start the player runs a ~20-frame test decode, measures the latency, and caches the verdict per device model. if the test decode comes back slow, it forces a lower profile instead of trusting the capability flags.

the metered-data part

prefetching is great on wifi and rude on a 1.5 GB/day plan, which a lot of users actually have. the player checks isActiveNetworkMetered() and the Data Saver state before any prefetch: on a metered network it skips prefetch entirely and shrinks the buffer instead of filling it. that one check is the whole feature, and it saves more data than any compression tweak.

what it looks like now

  • APK is still 1.17 MB, RAM stays under 15 MB during playback
  • Windows build is 29.5 MB (WebView2 bootstrap)
  • no account, no telemetry, no ads

grab it here: a player that respects your battery — the apk (1.17 mb) for Android, the windows build (29.5 mb) for PC.

full disclosure: i'm the developer of RKMovies. this is a build diary of the changes above, not an ad.

if you try it on a low-end phone i'd genuinely like to know whether the thermal drop actually helps, or if your phone still cooks. what's the hottest your phone gets during a long video session?

Top comments (0)