<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: hammi</title>
    <description>The latest articles on DEV Community by hammi (@hammiwor).</description>
    <link>https://dev.to/hammiwor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4177732%2F3cd92fc7-635e-4d54-ba93-55561d1b2b58.png</url>
      <title>DEV Community: hammi</title>
      <link>https://dev.to/hammiwor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hammiwor"/>
    <language>en</language>
    <item>
      <title>how my 1.17 mb player renders webvtt subtitles on a canvas (no amoled burn-in, no dom churn)</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Mon, 23 Nov 2026 23:04:34 +0000</pubDate>
      <link>https://dev.to/hammiwor/how-my-117-mb-player-renders-webvtt-subtitles-on-a-canvas-no-amoled-burn-in-no-dom-churn-2gpo</link>
      <guid>https://dev.to/hammiwor/how-my-117-mb-player-renders-webvtt-subtitles-on-a-canvas-no-amoled-burn-in-no-dom-churn-2gpo</guid>
      <description>&lt;p&gt;i'm the dev behind &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;RKMovies&lt;/a&gt;, a 1.17 mb native 4k player for android, with a 29.5 mb windows build on the side. one constraint i gave myself early: subtitles must not burn in amoled screens, and total playback ram has to stay under 15 mb on 2 gb phones. this is how the subtitle engine actually works.&lt;/p&gt;

&lt;h2&gt;
  
  
  dom subtitles are the enemy
&lt;/h2&gt;

&lt;p&gt;the obvious implementation is a div stacked over the video that you re-render on every cue. two problems with that. on amoled, every static pixel is a burn-in timer, and subtitle blocks sit still for seconds at the bottom of the frame. and re-creating dom nodes per cue on a budget phone is gc churn you feel as jank during seeks.&lt;/p&gt;

&lt;h2&gt;
  
  
  canvas overlay with a dirty flag
&lt;/h2&gt;

&lt;p&gt;so the player renders webvtt cues onto a single canvas layered above the video surface. the parser keeps a sorted cue list plus a sliding window of the 3 active cues, and the canvas only repaints when that active set changes or when you seek. text metrics are measured once per style run and cached, so a two hour movie does not re-measure the same words thousands of times.&lt;/p&gt;

&lt;p&gt;one canvas layer costs one extra composite pass on the gpu. the mediacodec hw decode path underneath is untouched, which is why the ram number holds under 15 mb during 4k hevc playback.&lt;/p&gt;

&lt;h2&gt;
  
  
  the srt to webvtt hop
&lt;/h2&gt;

&lt;p&gt;upstream sources hand out srt, players want webvtt, so the app converts in memory at load: drop the index line, swap comma decimals for dot timestamps, re-wrap overlong lines. it's a small state machine and it keeps the bundled parser tiny, which matters when your whole apk is 1.17 mb.&lt;/p&gt;

&lt;p&gt;grab the android build on &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the apk download page&lt;/a&gt;, or the windows one on &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the pc edition page&lt;/a&gt;. the home page is &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;here&lt;/a&gt; if you want the full feature list.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>i pointed a mitm proxy at my own 1.17 mb player for a week. here is every request it made</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Wed, 18 Nov 2026 22:54:57 +0000</pubDate>
      <link>https://dev.to/hammiwor/i-pointed-a-mitm-proxy-at-my-own-117-mb-player-for-a-week-here-is-every-request-it-made-2igf</link>
      <guid>https://dev.to/hammiwor/i-pointed-a-mitm-proxy-at-my-own-117-mb-player-for-a-week-here-is-every-request-it-made-2igf</guid>
      <description>&lt;p&gt;I build &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;the player's home page&lt;/a&gt;, a small media player client for Android and Windows. the apk is 1.17 mb, the exe is 29.5 mb. the landing page claims "zero telemetry" and "no account". claims like that are cheap, so i tried to disprove my own claim.&lt;/p&gt;

&lt;p&gt;setup: i ran the app behind mitmproxy on a test phone with a fresh profile. watched a full movie, browsed around, switched audio tracks, loaded subtitles, killed the app mid-playback, reinstalled it. one week of normal use, every tls handshake logged.&lt;/p&gt;

&lt;p&gt;the full list of outbound requests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the video stream urls themselves. that is the product, nothing else rides on them&lt;/li&gt;
&lt;li&gt;one dns lookup per stream host&lt;/li&gt;
&lt;li&gt;nothing else&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;no analytics, no crash reporter, no ads sdk, no fingerprinting calls, not even a version check. you update by re-downloading from &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the 1.17 mb apk download&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;the interesting part was what i had to delete to get there. an early build shipped with a crash reporter behind an "opt in" default. i told myself that was fine. it was not, and honestly the consent dialog was doing more work than the reporter ever did. the fix was not a toggle, it was removing the dependency. today the android manifest asks for exactly three things: INTERNET, ACCESS_NETWORK_STATE, POST_NOTIFICATIONS. no READ_PHONE_STATE, no ad id, storage is scoped through the system picker.&lt;/p&gt;

&lt;p&gt;the windows build is the same story. it opens the stream url and a local file dialog. that is the whole network surface. get it from &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the pc installer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;if you do not trust me: install the apk, block its network except the stream host, and watch it still work. or just decompile the apk and read the manifest yourself.&lt;/p&gt;

&lt;p&gt;full disclosure: i am the developer of RKMovies.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>The runtime memory budget of my 1.17 MB player: keeping playback under 15 MB RAM</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Sat, 14 Nov 2026 20:57:21 +0000</pubDate>
      <link>https://dev.to/hammiwor/the-runtime-memory-budget-of-my-117-mb-player-keeping-playback-under-15-mb-ram-31p5</link>
      <guid>https://dev.to/hammiwor/the-runtime-memory-budget-of-my-117-mb-player-keeping-playback-under-15-mb-ram-31p5</guid>
      <description>&lt;h1&gt;
  
  
  The runtime memory budget of my 1.17 MB player: keeping playback under 15 MB RAM
&lt;/h1&gt;

&lt;p&gt;Quick disclosure up front: I build &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;RKMovies&lt;/a&gt;, an ultra-lightweight media player for Android and Windows. This is a dev diary about one number on that page: the RAM figure.&lt;/p&gt;

&lt;p&gt;Everyone asks about APK size. Nobody asks what the app does with RAM once it is running, and that is the number that actually decides whether a player survives on a 2 GB phone from 2018. So I profiled it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I measured
&lt;/h2&gt;

&lt;p&gt;Setup: Android 11 phone with 2 GB RAM, playing a 1080p H.264 file with a 5.1 audio track and an SRT subtitle file. Profiler: Android Studio Memory Profiler plus &lt;code&gt;dumpsys meminfo&lt;/code&gt; on the release build. APK is 1.17 MB; install size is a bit more because of the extracted native libs.&lt;/p&gt;

&lt;p&gt;Result: steady-state playback sits under 15 MB of app RAM. Not "15 MB at idle, 200 MB when playing". Under 15 MB &lt;em&gt;while playing&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the bytes actually go
&lt;/h2&gt;

&lt;p&gt;This is the part that surprised me. The video frames are not in my memory budget at all. The decoder owns the frame buffers and they live in the codec's own process memory (or shared memory with the surface), not in the app heap. If you copy frames into a Bitmap, you are doing it wrong. That alone can eat 30-80 MB on a 1080p stream. My player renders straight to a SurfaceView and never touches a pixel in app memory.&lt;/p&gt;

&lt;p&gt;What &lt;em&gt;is&lt;/em&gt; in my heap during playback:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The subtitle cue window. I parse SRT, convert to WebVTT, and keep only the cues inside a 30-second sliding window. That is a few KB, not the whole file.&lt;/li&gt;
&lt;li&gt;One poster bitmap, downscaled with inSampleSize before decode. A full-res poster from the web is 10-20 MB decoded; mine loads at thumbnail size, a few hundred KB.&lt;/li&gt;
&lt;li&gt;The gesture HUD state: two floats and a timestamp. That is it.&lt;/li&gt;
&lt;li&gt;Watch state (position, audio track, subtitle track) goes to IndexedDB on every pause, not kept as a big in-memory model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The mistakes I made first
&lt;/h2&gt;

&lt;p&gt;Version 0.9 kept the whole subtitle file parsed in memory, cached every poster it had ever shown, and copied one frame into a Bitmap for the "now playing" thumbnail. On the 2 GB phone it got OOM-killed mid-movie. The fix was not heroic engineering. It was deleting code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sliding window for cues instead of whole-file parse.&lt;/li&gt;
&lt;li&gt;LRU of size 1 for posters.&lt;/li&gt;
&lt;li&gt;Decoder output straight to surface, thumbnail from a downscaled stream.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deleting code is the best optimization. A 1.17 MB APK is not impressive because the binary is small; it is impressive because there is almost nothing in it to allocate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Windows side
&lt;/h2&gt;

&lt;p&gt;The 29.5 MB installer is mostly the WebView2 bootstrapper, not my code. Same rule applies on desktop: hardware decode via NVDEC/QuickSync with DXVA fallback, frames never copied into managed memory, and the whole UI is one canvas for the gesture layer so the compositor does the work.&lt;/p&gt;

&lt;p&gt;If you want to poke at it: &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;get the Android build&lt;/a&gt; (1.17 MB, sideload) or &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the exe download page&lt;/a&gt; for Windows. Hardware-accelerated decode, dual-zone gesture HUD, multi-audio tracks, WebVTT subtitles, zero telemetry, no account. I made it because every player I tried ate storage and RAM my old phone did not have.&lt;/p&gt;

&lt;p&gt;What memory tricks do you use to keep small apps small? Genuinely curious what I am still missing.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>My 1.17 MB player now listens to the battery: thermal-aware decode + a metered-data mode</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Fri, 13 Nov 2026 20:52:12 +0000</pubDate>
      <link>https://dev.to/hammiwor/my-117-mb-player-now-listens-to-the-battery-thermal-aware-decode-a-metered-data-mode-3agg</link>
      <guid>https://dev.to/hammiwor/my-117-mb-player-now-listens-to-the-battery-thermal-aware-decode-a-metered-data-mode-3agg</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  the thermal part
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;so the player now registers a &lt;code&gt;PowerManager&lt;/code&gt; thermal status listener while playback is active (API 29+, no polling, nothing runs in the background). on &lt;code&gt;THERMAL_STATUS_MODERATE&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;one more trap i hit: &lt;code&gt;MediaCodecInfo&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  the metered-data part
&lt;/h2&gt;

&lt;p&gt;prefetching is great on wifi and rude on a 1.5 GB/day plan, which a lot of users actually have. the player checks &lt;code&gt;isActiveNetworkMetered()&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  what it looks like now
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;APK is still 1.17 MB, RAM stays under 15 MB during playback&lt;/li&gt;
&lt;li&gt;Windows build is 29.5 MB (WebView2 bootstrap)&lt;/li&gt;
&lt;li&gt;no account, no telemetry, no ads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;grab it here: &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;a player that respects your battery&lt;/a&gt; — &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the apk (1.17 mb)&lt;/a&gt; for Android, &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the windows build (29.5 mb)&lt;/a&gt; for PC.&lt;/p&gt;

&lt;p&gt;full disclosure: i'm the developer of RKMovies. this is a build diary of the changes above, not an ad.&lt;/p&gt;

&lt;p&gt;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?&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Why my 1.17 MB player opens in under 400 ms cold: zero content providers, lazy init, and a startup window that only draws a color</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Fri, 13 Nov 2026 01:49:01 +0000</pubDate>
      <link>https://dev.to/hammiwor/why-my-117-mb-player-opens-in-under-400-ms-cold-zero-content-providers-lazy-init-and-a-startup-1i1h</link>
      <guid>https://dev.to/hammiwor/why-my-117-mb-player-opens-in-under-400-ms-cold-zero-content-providers-lazy-init-and-a-startup-1i1h</guid>
      <description>&lt;p&gt;Everyone talks about download size. Nobody talks about the first 400 ms. My player is 1.17 MB on Android, and on a 2 GB Moto G Play the difference between "opens instantly" and "opens eventually" is entirely in what runs before the first frame.&lt;/p&gt;

&lt;p&gt;I profiled cold starts with &lt;code&gt;adb shell am start -W&lt;/code&gt; and Macrobenchmark, and the numbers matched what the Android docs say: TTID (time to initial display) is what users feel, TTFD is what they can actually use. A splash screen gets you a good TTID. It does nothing for TTFD. So I optimized both, separately.&lt;/p&gt;

&lt;p&gt;What I cut:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Zero ContentProviders. No androidx.startup, nothing auto-initializing. A 1.17 MB APK cannot afford a provider doing disk I/O on the main thread before onCreate finishes. Everything is lazy, pulled on first use.&lt;/li&gt;
&lt;li&gt;The startup window only draws a color. windowBackground on the theme, no bitmap, no inflation. First frame lands in tens of ms because there is nothing to inflate.&lt;/li&gt;
&lt;li&gt;The video surface is created but not attached until the first file opens. SurfaceView/TextureView creation is not free on old devices, and the home screen does not need it.&lt;/li&gt;
&lt;li&gt;All JSON parsing, thumbnail decode and list binding happens after the first frame is drawn, chunked so the main thread never blocks longer than one frame.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The result on the Moto G Play: cold start to first frame is around 250-350 ms, and the home list is interactive under 500 ms. That is the whole trick. There is no library magic in a 1.17 MB binary; there is just refusing to do work before the user sees anything.&lt;/p&gt;

&lt;p&gt;I also tried baseline profiles for a while and dropped them. On a binary this small the AOT compilation tax on install was not worth the jank reduction, and Play already does partial AOT on install for API 28+. Startup profiles via dex layout were the bigger win and they cost zero runtime bytes.&lt;/p&gt;

&lt;p&gt;Disclosure: I build RKMovies, an ultra-lightweight 4K player client for Android and Windows (1.17 MB APK, 29.5 MB installer, hardware decode, multi-audio, WebVTT subs, no account, zero telemetry). More here: &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;the home page of the thing&lt;/a&gt;, &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the 1.17 mb sideload link&lt;/a&gt;, &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the windows installer page&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>I swapped audio tracks mid-movie without a rebuffer. Here is how my 1.17 MB player does it</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Thu, 12 Nov 2026 20:54:49 +0000</pubDate>
      <link>https://dev.to/hammiwor/i-swapped-audio-tracks-mid-movie-without-a-rebuffer-here-is-how-my-117-mb-player-does-it-3pf0</link>
      <guid>https://dev.to/hammiwor/i-swapped-audio-tracks-mid-movie-without-a-rebuffer-here-is-how-my-117-mb-player-does-it-3pf0</guid>
      <description>&lt;p&gt;Indian releases now ship four or five audio languages on the same stream. Telugu original, Hindi dub, Tamil dub, sometimes Kannada and Malayalam too. The stock players pick one at start, and if you switch, half the time the video re-seeks and re-buffers. So people just stay on the wrong dub.&lt;/p&gt;

&lt;p&gt;My player is 1.17 MB on Android and runs on the system MediaPlayer, so there was no library to lean on. The trick turned out to be boring: never tear the player down.&lt;/p&gt;

&lt;p&gt;What I actually do:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;After prepare, I read &lt;code&gt;player.getTrackInfo()&lt;/code&gt; once. It returns every track with its type and language, so I filter &lt;code&gt;TRACK_TYPE_AUDIO&lt;/code&gt; and build a small picker from &lt;code&gt;getLanguage()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Switching is just &lt;code&gt;selectTrack(index)&lt;/code&gt; on the same player instance. The video track stays selected, the decoder never restarts, and there is no rebuffer. On a 2 GB Moto G Play the swap lands in under 300 ms with no seek-bar jump.&lt;/li&gt;
&lt;li&gt;The catch: some OEM players still stall briefly when the audio renderer re-inits. So I keep the old audio track selected until the new one is live, then deselect it. Ugly, but it hides the hiccup.&lt;/li&gt;
&lt;li&gt;UI is a bottom sheet listing the languages with the active one ticked. No settings maze.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I measured cold start to first frame against audio-switch latency on the same file. The switch is consistently 5-10x faster than a re-seek, and RAM stays flat because nothing new gets allocated.&lt;/p&gt;

&lt;p&gt;The whole audio layer is maybe 200 lines. That is the point of keeping the APK at 1.17 MB: every feature has to justify its bytes, and track switching earns its keep because multi-audio releases are the norm now, not the exception.&lt;/p&gt;

&lt;p&gt;Disclosure: I build RKMovies, an ultra-lightweight 4K player client for Android and Windows (1.17 MB APK, 29.5 MB installer, hardware decode, multi-audio, WebVTT subs, no account, zero telemetry). More here: &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;the project homepage&lt;/a&gt;, &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the sideload apk page&lt;/a&gt;, &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the windows download page&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Audio focus is the feature nobody demos (and every player needs)</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Thu, 12 Nov 2026 01:23:13 +0000</pubDate>
      <link>https://dev.to/hammiwor/audio-focus-is-the-feature-nobody-demos-and-every-player-needs-1aah</link>
      <guid>https://dev.to/hammiwor/audio-focus-is-the-feature-nobody-demos-and-every-player-needs-1aah</guid>
      <description>&lt;p&gt;You can demo 4K in a trailer. You cannot demo "the movie pauses politely when your mum calls". But users feel that one every single day, and on a player with no account and no telemetry, it has to be handled locally and correctly on the first try.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually happens
&lt;/h2&gt;

&lt;p&gt;Android sends audio focus events: another app wants the audio (navigation, a call), you get ducked, transient loss, permanent loss. Ignore them and your movie keeps playing over someone's phone call. The app review then says "ruined my call" and you never hear the end of it.&lt;/p&gt;

&lt;p&gt;Bluetooth headphones reconnect with a 1-3 s delay. Wired headsets get yanked mid-scene. &lt;code&gt;AudioManager&lt;/code&gt; reports both through focus changes and the becoming-noisy broadcast, but only if you actually registered for them.&lt;/p&gt;

&lt;p&gt;On the Windows build the same problem exists inside WebView2, except the OS audio session ducking does not come for free. You wire it yourself or you do not get it.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I did it without a media framework
&lt;/h2&gt;

&lt;p&gt;I skipped media3/exoplayer partly to keep the APK at 1.17 MB, which means audio focus is my code, not a library's. The core of it is one &lt;code&gt;OnAudioFocusChangeListener&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;permanent loss: pause and remember position&lt;/li&gt;
&lt;li&gt;transient loss: pause, resume on regain, with a 30 s guard so a notification blip does not restart playback&lt;/li&gt;
&lt;li&gt;duck: drop volume to 20% instead of pausing, like a good citizen&lt;/li&gt;
&lt;li&gt;becoming noisy (headset unplug): pause immediately, because the user cannot hear the movie anymore anyway&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bluetooth is the annoying one. An A2DP reconnect can take a couple of seconds and some OEMs fire the noisy event twice. So I debounce: only pause if the event is still true 500 ms later.&lt;/p&gt;

&lt;p&gt;Position restore is one IndexedDB row per file (&lt;code&gt;profile|path|se|ep -&amp;gt; positionMs&lt;/code&gt;). On focus regain I seek back to it. That is the whole feature. Maybe 400 lines including the Windows side.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it still breaks
&lt;/h2&gt;

&lt;p&gt;Some Chinese OEM battery savers (Xiaomi, Realme) kill the process outright instead of pausing it. Nothing in-app fixes that. The fix is "disable battery saver for the app", and I cannot do that for the user.&lt;/p&gt;

&lt;p&gt;During a real phone call Android sometimes hands focus back before the call has actually ended. My 30 s guard catches most of it, not all of it.&lt;/p&gt;

&lt;p&gt;And the WebView2 side still does not duck automatically on Windows. I have to hook the core audio session events myself. That one is honestly still on my todo list.&lt;/p&gt;

&lt;p&gt;The numbers I keep quoting: the APK is 1.17 MB, the Windows installer is 29.5 MB, playback stays under 15 MB RAM because decode is hardware (MediaCodec on Android, NVDEC/QuickSync on PC). Audio focus costs zero bytes of that. It is just correct event handling.&lt;/p&gt;

&lt;p&gt;If you want to try the player: &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;the player's home page&lt;/a&gt; is the start, &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the android download page&lt;/a&gt; has the APK, and &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the pc installer page&lt;/a&gt; has the Windows build. I'm the developer, fyi.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Dual-zone gesture HUD on a canvas: brightness, volume, seek with zero DOM (and zero battery tax)</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Wed, 11 Nov 2026 22:24:42 +0000</pubDate>
      <link>https://dev.to/hammiwor/dual-zone-gesture-hud-on-a-canvas-brightness-volume-seek-with-zero-dom-and-zero-battery-tax-1dbf</link>
      <guid>https://dev.to/hammiwor/dual-zone-gesture-hud-on-a-canvas-brightness-volume-seek-with-zero-dom-and-zero-battery-tax-1dbf</guid>
      <description>&lt;h1&gt;
  
  
  Dual-zone gesture HUD on a canvas: brightness, volume, seek with zero DOM (and zero battery tax)
&lt;/h1&gt;

&lt;p&gt;Most webview video players do gestures the lazy way: absolutely-positioned DOM overlays, a JS hit-test on every &lt;code&gt;touchmove&lt;/code&gt;, rAF loops that never stop. On a 2 GB RAM budget phone in India, that means the main thread wakes up dozens of times a second just because your thumb moved. I wanted none of that.&lt;/p&gt;

&lt;p&gt;So the HUD in my player is a single &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; painted over the &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element. No DOM nodes for the overlay, no persistent animation loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;One &lt;code&gt;pointerdown&lt;/code&gt; splits the screen into zones: left half = vertical drag for brightness, right half = vertical drag for volume. Horizontal drag anywhere = seek, with a live time label. Double-tap right/left = skip 10 s. Long-press = 2x speed. Tap = play/pause.&lt;/li&gt;
&lt;li&gt;The canvas only repaints while a finger is down. &lt;code&gt;requestAnimationFrame&lt;/code&gt; is requested on &lt;code&gt;pointerdown&lt;/code&gt; and cancelled on &lt;code&gt;pointerup&lt;/code&gt;. Between gestures the canvas is fully transparent and the compositor does the work.&lt;/li&gt;
&lt;li&gt;All the numbers (brightness %, volume %, seek delta) are drawn as canvas text with a shadow, not DOM. That cost me roughly 30 KB of APK and nothing at runtime.&lt;/li&gt;
&lt;li&gt;Brightness is applied via &lt;code&gt;WindowManager.LayoutParams.screenBrightness&lt;/code&gt;, not a filter over the video. A filter forces a full-surface re-composite on every frame. The window flag does it in the display pipeline, basically free.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The APK is 1.17 MB total and playback sits under 15 MB RAM at 4K, because the decode itself is the system's job: MediaCodec on Android, NVDEC/QuickSync in the Windows build. Gestures are just compositing on top; hardware decode is what keeps the battery sane during a two-hour movie.&lt;/p&gt;

&lt;h2&gt;
  
  
  The honest trade-offs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A canvas HUD has no accessibility tree. Screen readers can't see the brightness readout. I'm still working on that one.&lt;/li&gt;
&lt;li&gt;Canvas text scaling on weird DPI buckets (some Xiaomi/Motorola builds) needs a manual calibration factor.&lt;/li&gt;
&lt;li&gt;On Android 10+ edge-to-edge, the left-edge system back gesture collides with my left-zone vertical drags. I shrink the gesture zone by 24 px on those builds.&lt;/li&gt;
&lt;li&gt;Software decode on very old phones can still stutter at high bitrate. Hardware decode is what makes this smooth, and it's also why the APK stays at 1.17 MB: zero bundled codec bytes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building a player for old phones and metered data plans, draw your HUD on a canvas and only while touching. Your users' batteries will notice.&lt;/p&gt;

&lt;p&gt;This is a dev diary from my side project, &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;RKMovies&lt;/a&gt; — the project home is at &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;my side project's home&lt;/a&gt;, with the &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;apk install page&lt;/a&gt; for Android and the &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;windows exe page&lt;/a&gt; for the PC build. I'm the developer, fyi.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>i dissected my own 1.17 mb apk: where every byte actually goes</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Wed, 11 Nov 2026 20:08:28 +0000</pubDate>
      <link>https://dev.to/hammiwor/i-dissected-my-own-117-mb-apk-where-every-byte-actually-goes-3na6</link>
      <guid>https://dev.to/hammiwor/i-dissected-my-own-117-mb-apk-where-every-byte-actually-goes-3na6</guid>
      <description>&lt;p&gt;i'm the developer of rkmovies, a 4k media player that ships as &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the tiny android apk page&lt;/a&gt; (1.17 mb) and &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the windows setup page&lt;/a&gt; (29.5 mb), with the web app on &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;my little project site&lt;/a&gt;. people keep asking how an apk that plays 4k stays under 2 mb, so i ran apkanalyzer on my own release build and read the breakdown. this is what's inside.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the honest headline: there's almost nothing in it.&lt;/strong&gt; a universal apk has four big buckets: &lt;code&gt;classes.dex&lt;/code&gt; (your code), &lt;code&gt;res/&lt;/code&gt; + &lt;code&gt;resources.arsc&lt;/code&gt; (layouts, strings, images), &lt;code&gt;lib/&lt;/code&gt; (native .so per abi), and &lt;code&gt;META-INF/&lt;/code&gt; (signatures). mine has no &lt;code&gt;lib/&lt;/code&gt; at all — zero native libraries — because the app is a webview shell that hands decoding to the device's mediacodec. that single decision is the whole size story.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dex was the first fight.&lt;/strong&gt; r8 full mode + &lt;code&gt;shrinkResources&lt;/code&gt; on the release build strips unreachable code and unused resources. the rule i live by now: features don't cost size, dependencies do. every library i add is measured with &lt;code&gt;apkanalyzer -h apk file-size&lt;/code&gt; before and after. one transitive dependency once added 300 kb quietly — the compare view in apk analyzer caught it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;resources were the second fight.&lt;/strong&gt; vector drawables instead of pngs, webp where a raster is unavoidable, and &lt;code&gt;localeFilters&lt;/code&gt; so i don't ship string tables for languages the app doesn't have. resources.arsc is sneaky — it holds every string of every shipped locale, and libraries drag their own in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;abi splits are the classic trap.&lt;/strong&gt; each native lib ships one copy per abi (arm64, armeabi-v7a, x86, x86_64) — 4x the bytes for one feature. play store solves this with app bundles; outside the store you either split per abi or filter with &lt;code&gt;ndk { abiFilters }&lt;/code&gt;. i ship no .so, so i skipped the whole problem, and i keep &lt;code&gt;useLegacyPackaging = false&lt;/code&gt; habits in mind for when i do add native code: uncompressed, page-aligned .so loads straight from the apk instead of double-copying to disk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what's left is overhead you can't remove:&lt;/strong&gt; the manifest, the dex header, the v2 signature block. at 1.17 mb those are a rounding error.&lt;/p&gt;

&lt;p&gt;the general pattern: measure with apkanalyzer first, cut the biggest bucket, repeat. size budgets work like money budgets — you don't save by skipping coffee, you save by knowing where the rent goes.&lt;/p&gt;

&lt;p&gt;if you're building small: start with what the os gives you, add a dependency only when you've measured the wall, and keep the analyzer in your release routine.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>i added a vast ad gate to my 1.17 mb player and the ad network only talks to mobile user agents</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Wed, 11 Nov 2026 00:57:51 +0000</pubDate>
      <link>https://dev.to/hammiwor/i-added-a-vast-ad-gate-to-my-117-mb-player-and-the-ad-network-only-talks-to-mobile-user-agents-p00</link>
      <guid>https://dev.to/hammiwor/i-added-a-vast-ad-gate-to-my-117-mb-player-and-the-ad-network-only-talks-to-mobile-user-agents-p00</guid>
      <description>&lt;p&gt;Disclosure: I'm the developer of RKMovies, a small 4K media player client. It ships as a 1.17 MB APK and a 29.5 MB Windows installer. The web app lives at &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;this little player of mine&lt;/a&gt;, with the &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;android apk download page&lt;/a&gt; and the &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;windows desktop build page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The app shows one short ad before playback, from mainstream family safe networks. Keeping that gate working this week turned into a debugging war, so here are the actual bugs.&lt;/p&gt;

&lt;h3&gt;
  
  
  The empty VAST
&lt;/h3&gt;

&lt;p&gt;We fetch a VAST XML tag from the ad network and play whatever it returns. Suddenly, desktop user agents from many IPs got an empty VAST back (no ads at all) while mobile UAs got full inventory from the same IP. Same request, same IP, only the User-Agent string differed. The fix was one line: fetch the VAST tag with a mobile UA. It feels wrong, but it works and it's still in the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  The dead CDN
&lt;/h3&gt;

&lt;p&gt;Then the CDN the VAST pointed at turned out to be publicly unresolvable. Ad media 403'd and 502'd and the gate looped forever. The fix: the ad media allowlist now self heals from the hosts the served VAST actually uses, instead of a hardcoded list. When the network rotated CDNs, the next VAST response told us the new host and the allowlist learned it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Count bytes, don't trust the player
&lt;/h3&gt;

&lt;p&gt;"Did the ad play?" is a question the video element answers with a lie. Stalled streams, errored media, a 30 second chip spinning on nothing. So the proxy and the Android shell count actual ad bytes (more than 1 MB and at least 95% of the stream) through /api/admedia, and only then issue a one time token. The play and download endpoints return 4030 without it. The 12 hour unlock now survives app and proxy restarts. Before, it lived in memory only.&lt;/p&gt;

&lt;h3&gt;
  
  
  The watchdog
&lt;/h3&gt;

&lt;p&gt;The connect timeout on ad media used to be 300 seconds, so one dead CDN hung requests for minutes. Now it's 6 seconds, plus a client side watchdog that fails non loading ad media immediately, and 6 consecutive video errors stop the pod loop and show the unlock instead of resetting the countdown. The countdown state is shared across the whole ad pod now, so the second ad no longer restarts at 30 seconds.&lt;/p&gt;

&lt;p&gt;What I learned: ad networks assume you are a big app whose browser fingerprint matches your traffic. A 1.17 MB webview app does not get to make those assumptions. Feature detect everything, count bytes yourself, and never trust a 200.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>why i skipped exoplayer and bet on the system mediaplayer for a 1.17 mb player</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Tue, 10 Nov 2026 22:23:12 +0000</pubDate>
      <link>https://dev.to/hammiwor/why-i-skipped-exoplayer-and-bet-on-the-system-mediaplayer-for-a-117-mb-player-39bl</link>
      <guid>https://dev.to/hammiwor/why-i-skipped-exoplayer-and-bet-on-the-system-mediaplayer-for-a-117-mb-player-39bl</guid>
      <description>&lt;p&gt;i'm the developer of rkmovies — a 4k media player that ships as &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;grab the apk here&lt;/a&gt; (1.17 mb) and &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;install it on windows&lt;/a&gt; (29.5 mb), with the web app at &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;this thing i'm building&lt;/a&gt;. when i started, every android video tutorial pointed at media3/exoplayer. i went the other way: the app bundles zero media libraries and plays through the webview's &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element, which hands decoding to the device's mediacodec. here's the math that decided it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the size tax.&lt;/strong&gt; media3/exoplayer costs roughly 1–3 mb of apk depending on which modules you pull in, before any software decoder extensions — that's google's own estimate, and r8 shrinking gets maybe 40% of it back for a typical player. for an app whose whole point is running on a 2 gb budget phone on a 1.5 gb/day data plan, 1–3 mb is 100–250% of my entire binary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what the megabytes buy.&lt;/strong&gt; consistent behavior across devices, dash + hls adaptive streaming out of the box, swappable renderers, gapless playlists. real stuff. what the system mediaplayer costs you: behavior shifts across oem roms, hls support varies by android version, and you can't patch a decoder bug on a user's phone — you wait for the os update or you route around it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;my workaround.&lt;/strong&gt; feature-detect at runtime and keep a fallback chain. if &lt;code&gt;video.canPlayType('application/vnd.apple.mpegurl')&lt;/code&gt; says maybe, i still try hls — most android 8+ webviews handle it through the system player. where a rom chokes, i fall back to the best mp4 the source offers. every step is a try/catch because webviews throw different errors instead of returning undefined. i learned that on a budget micromax device.&lt;/p&gt;

&lt;p&gt;the general pattern i've landed on: features don't cost size, dependencies do. the gesture hud, multi-audio track switching (hindi/tamil/telugu/english), webvtt subtitles, picture-in-picture — all of it is js calling apis the platform already exposes. zero bytes of apk.&lt;/p&gt;

&lt;p&gt;if you're building something small: start with what the os gives you. add a library only when you hit a wall the platform can't solve, and measure the wall before you buy the ladder.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Why my PWA still ships a 29.5 MB Windows exe (WebView2 bootstrap, offline cache, one instance)</title>
      <dc:creator>hammi</dc:creator>
      <pubDate>Mon, 09 Nov 2026 18:41:07 +0000</pubDate>
      <link>https://dev.to/hammiwor/why-my-pwa-still-ships-a-295-mb-windows-exe-webview2-bootstrap-offline-cache-one-instance-4019</link>
      <guid>https://dev.to/hammiwor/why-my-pwa-still-ships-a-295-mb-windows-exe-webview2-bootstrap-offline-cache-one-instance-4019</guid>
      <description>&lt;p&gt;I build RKMovies, a small media player that started life as a PWA. The Android APK is 1.17 MB. People keep asking why there is also a Windows installer, and why it sits at 29.5 MB when the web app is way smaller. This is the build diary.&lt;/p&gt;

&lt;h2&gt;
  
  
  the PWA does the heavy lifting
&lt;/h2&gt;

&lt;p&gt;The whole player is HTML/CSS/JS served from &lt;a href="https://rkmovies.dpdns.org" rel="noopener noreferrer"&gt;the project page&lt;/a&gt;. It installs as a PWA, works offline after the first load, and updates itself by swapping the service worker. On Android I wrap the same bundle in a webview and ship &lt;a href="https://rkmovies.dpdns.org/apk" rel="noopener noreferrer"&gt;the 1.17 MB Android APK&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  why an exe at all
&lt;/h2&gt;

&lt;p&gt;A lot of users (mostly family TV setups on old PCs) want a desktop icon and a double-click. They do not want to open a browser and install a PWA from a menu. So the desktop build is the same web bundle plus a WebView2 bootstrapper.&lt;/p&gt;

&lt;h2&gt;
  
  
  what actually costs the 29.5 MB
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;the WebView2 runtime bootstrapper, which is most of the size&lt;/li&gt;
&lt;li&gt;a pre-cached app shell so the first launch works fully offline&lt;/li&gt;
&lt;li&gt;the player code itself, which is under 2 MB&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I could ship an evergreen WebView2 reference and cut the installer down hard, but on the old machines this app targets the runtime is usually missing, and a separate runtime download scares people off. Self-contained wins on support tickets even though it costs megabytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  the boring parts that matter
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;a single-instance lock, so double-clicking the icon never spawns five windows&lt;/li&gt;
&lt;li&gt;the exe registers a custom URL handler and forwards the link to the already-running instance&lt;/li&gt;
&lt;li&gt;updates reuse the same multi-endpoint config check the PWA uses, then swap files only while no window is open&lt;/li&gt;
&lt;li&gt;zero telemetry; the only network calls are the ones the user triggers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On Windows, grab &lt;a href="https://rkmovies.dpdns.org/desktop" rel="noopener noreferrer"&gt;the 29.5 MB Windows installer&lt;/a&gt;. On Android, the APK above. Same player either way: hardware decode, gesture HUD, multi-audio tracks, WebVTT subtitles, under 15 MB RAM at runtime.&lt;/p&gt;

&lt;p&gt;Disclosure: I am the developer of RKMovies. Ask me anything about the packaging.&lt;/p&gt;

</description>
      <category>android</category>
      <category>performance</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
