<?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: Yonto Player</title>
    <description>The latest articles on DEV Community by Yonto Player (@yonto).</description>
    <link>https://dev.to/yonto</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%2F4227315%2F1beb75aa-252b-47b1-a706-c50b1dabc50e.png</url>
      <title>DEV Community: Yonto Player</title>
      <link>https://dev.to/yonto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yonto"/>
    <language>en</language>
    <item>
      <title>Offline downloads on Android: one state machine, a foreground service and HLS</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Wed, 25 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/offline-downloads-on-android-one-state-machine-a-foreground-service-and-hls-3o1k</link>
      <guid>https://dev.to/yonto/offline-downloads-on-android-one-state-machine-a-foreground-service-and-hls-3o1k</guid>
      <description>&lt;p&gt;A download sounds like the easy part of a media app: fetch a file, play it later. The transfer has to survive the screen turning off, a dropped connection and the process being reclaimed. The player has to prefer the local file over the stream, and the title page has to work with no connection.&lt;/p&gt;

&lt;p&gt;This post is about how that is built in Yonto Player on Android phones and tablets, and about the few decisions that keep it small.&lt;/p&gt;

&lt;h2&gt;
  
  
  One record, one state machine
&lt;/h2&gt;

&lt;p&gt;Every download is a &lt;code&gt;DownloadRecord&lt;/code&gt;, keyed by the same play key that a title's resume point uses. That choice matters later: the file a download becomes is found by the identity History already uses, so the downloaded copy of a title in your own library is found the way its resume point is.&lt;/p&gt;

&lt;p&gt;The record has five states, and the rules for moving between them live in one function in the shared core:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the download state machine, not the exact source.&lt;/span&gt;
&lt;span class="k"&gt;enum&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;QUEUED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;RUNNING&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;PAUSED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;FAILED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;DONE&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;sealed&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Started&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Progress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;done&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;total&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Pause&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Resume&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;Fail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Complete&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
    &lt;span class="kd"&gt;object&lt;/span&gt; &lt;span class="nc"&gt;Interrupted&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Returns the next record, or null when the event is not legal in this state.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nc"&gt;Record&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Record&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;QUEUED&lt;/span&gt;  &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Started&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RUNNING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Pause&lt;/span&gt;   &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PAUSED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Fail&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FAILED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;RUNNING&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Progress&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytesDone&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;done&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Pause&lt;/span&gt;       &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PAUSED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Fail&lt;/span&gt;     &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FAILED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Complete&lt;/span&gt;    &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DONE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Interrupted&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;QUEUED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;PAUSED&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;FAILED&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Resume&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;QUEUED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DONE&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details carry most of the weight. First, an illegal event returns &lt;code&gt;null&lt;/code&gt; and changes nothing, so a late "progress" that arrives after a pause is simply refused rather than corrupting the record. Second, &lt;code&gt;Interrupted&lt;/code&gt; sends a running download back to &lt;code&gt;QUEUED&lt;/code&gt;. If the process dies mid-transfer, the next start finds a record that says "running", marks it interrupted, and queues it again to continue from the bytes already on disk.&lt;/p&gt;

&lt;p&gt;A paused or failed download can be resumed, which queues it again. Cancelling and removing are not transitions. They delete the record, which keeps the machine small. The repository exposes one &lt;code&gt;apply(playKey, event)&lt;/code&gt; call, and an engine never writes a state itself, so the legal moves live in one place. A unit test tries each state against each event and checks that only the legal ones take effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  The engine is a seam
&lt;/h2&gt;

&lt;p&gt;How the bytes are fetched is the engine's business, so the shared code only knows an interface. A simplified sketch of it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the engine seam, not the exact source.&lt;/span&gt;
&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;DownloadEngine&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;DownloadRequest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;// queue it; start when the engine can&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;playKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;resume&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;playKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;playKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;// not done yet: stop, delete the partial file and the record&lt;/span&gt;
    &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;playKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;           &lt;span class="c1"&gt;// any state: delete the file and the record&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Android implementation reports every change through the repository's &lt;code&gt;apply&lt;/code&gt;, runs at most two transfers at a time, and waits when the network is not one the viewer allows. Downloads use Wi-Fi only by default, and turning that off lets a download use mobile data.&lt;/p&gt;

&lt;h2&gt;
  
  
  A foreground service for long transfers
&lt;/h2&gt;

&lt;p&gt;A transfer that lasts minutes cannot rely on the app being on screen. A foreground service of the data-sync type keeps a transfer running while the screen is off, and shows one ongoing notification with Pause and Cancel for the download that has run longest. When a download finishes or fails, a quiet notification says so.&lt;/p&gt;

&lt;p&gt;The service is thin. It keeps the process running and the notification current by watching the same records the screens watch, and its buttons call the same &lt;code&gt;pause&lt;/code&gt;, &lt;code&gt;resume&lt;/code&gt; and &lt;code&gt;cancel&lt;/code&gt; as the in-app ones. A paused download keeps a plain notification of its own, with Resume and Cancel, that does not hold the service open.&lt;/p&gt;

&lt;p&gt;Android 15 ends a data-sync service after a time limit, so the service handles the timeout callback, and the next fetch asks for a service again.&lt;/p&gt;

&lt;h2&gt;
  
  
  What can be downloaded
&lt;/h2&gt;

&lt;p&gt;The app plays your own library, and a download is a copy of a title from it for when you have no connection. Whether a title can be downloaded is decided in two steps when you touch Download. First comes the kind of source: titles that come over the network from your own Jellyfin, Emby or Plex server, a WebDAV folder or a cloud drive of your own can be downloaded, and a folder on the device cannot, because the file is already there. Then the stream the source gives for that title is checked:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A video that is one file&lt;/strong&gt; downloads as it is served, with a ranged request so a resume asks for the same file from where it stopped.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A video that comes in pieces&lt;/strong&gt; (an HLS playlist) is fetched piece by piece into one file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A live stream&lt;/strong&gt; is refused with a sentence: "A live stream can't be downloaded." A live channel has no end to save, and a playlist with no end marker counts as live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pieces that cannot be put into one file&lt;/strong&gt;, such as DASH or protected pieces, are refused with their own sentence rather than saved as something that will not play.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The refusal happens before anything starts, and a download that turns out to be pieces after it began stops with the same sentence in the Downloads list. Saying why is cheaper than leaving a ring that never fills.&lt;/p&gt;

&lt;p&gt;A note on use: downloads are for titles you have the right to keep, such as your own media. Please respect copyright and the terms of the services you use, and do not use downloads to copy or share content you have no right to. Yonto Player does not provide content and is not meant for piracy.&lt;/p&gt;

&lt;h3&gt;
  
  
  HLS as one file
&lt;/h3&gt;

&lt;p&gt;The HLS fetch reads the playlist, follows a master playlist to its highest-bandwidth variant, and appends each piece in order to the download's &lt;code&gt;.part&lt;/code&gt; file. Transport-stream pieces make a &lt;code&gt;.ts&lt;/code&gt; file, and fragmented-MP4 pieces make an &lt;code&gt;.mp4&lt;/code&gt;. AES-128 encrypted pieces are decrypted as they are written.&lt;/p&gt;

&lt;p&gt;Two things make it resumable. A small progress file beside the &lt;code&gt;.part&lt;/code&gt; records how many pieces are whole and how long the file was then, so a pause or a dropped connection continues from the last whole piece. And when the last piece lands, a transport stream is rewritten as an MP4 where the stream can be carried in one, because a transport stream has no index and a player has to search it to seek. The H.264 pictures and AAC frames are copied, not decoded, so it is a repackaging and not a re-encode. When the stream cannot be carried in an MP4, the transport stream is kept as it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing what to download
&lt;/h2&gt;

&lt;p&gt;A film that comes in several versions asks which one first. For a series, the Download button under Play opens a sheet of episodes with a box each. It starts with the next three unwatched episodes ticked, counted from the episode Resume would play, and two chips, Next 3 unwatched and All unwatched, tick episodes again. Select all and Select none work on a season. An episode that already has a download cannot be ticked, so a sheet never counts, sizes or starts the same file twice.&lt;/p&gt;

&lt;p&gt;Sizes are asked from the source when the sheet opens, and the total says "at least" until they arrive, because the sheet does not guess.&lt;/p&gt;

&lt;h2&gt;
  
  
  A finished download plays under the same key
&lt;/h2&gt;

&lt;p&gt;When a download is done, &lt;code&gt;playable(playKey)&lt;/code&gt; hands back a local file target for it. When the player redeems what to play, it asks for that key first and falls back to the source's stream only when there is no download. The record also keeps what a title page needs, such as the label, the poster and the picture format, so the page can be drawn with the source out of reach.&lt;/p&gt;

&lt;p&gt;With no connection, a title's page is built from its finished downloads. Each download becomes a playback option that saves its progress under the play key it was downloaded for, so the resume point, History and the next episode work as they do for a stream. Before a downloaded file is handed to the player, its size is checked against the record, and a file that is missing or the wrong size removes its download rather than offering something that will not play.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to take from it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Put the legal transitions in one pure function and make every engine go through it. The engine decides how to fetch, not what a download is allowed to do.&lt;/li&gt;
&lt;li&gt;Key the download by the identity playback already uses. Offline playback then needs no new concept.&lt;/li&gt;
&lt;li&gt;Decide what is downloadable from the kind of source and then the stream, and say why when it is not.&lt;/li&gt;
&lt;li&gt;For HLS, write to one file and record where you are, so a resume is a seek to the last whole piece.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/download-to-watch-offline/" rel="noopener noreferrer"&gt;Download to watch offline&lt;/a&gt; describes the buttons, the sheets and the Downloads list from the viewer's side.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/sources/" rel="noopener noreferrer"&gt;Sources&lt;/a&gt; covers which kinds of source the app can read.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/nas-and-media-server-on-android-phone-tablet/" rel="noopener noreferrer"&gt;Your media server and NAS on an Android phone or tablet&lt;/a&gt; is the setup that comes first.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/" rel="noopener noreferrer"&gt;The documentation&lt;/a&gt; is the index of everything the app does.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>architecture</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Plugin repos, an index and a CLI: how a plugin gets from a laptop to a TV</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Tue, 24 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/plugin-repos-an-index-and-a-cli-how-a-plugin-gets-from-a-laptop-to-a-tv-45j4</link>
      <guid>https://dev.to/yonto/plugin-repos-an-index-and-a-cli-how-a-plugin-gets-from-a-laptop-to-a-tv-45j4</guid>
      <description>&lt;p&gt;A plugin in Yonto Player is one JavaScript file that teaches the app to talk to one kind of server. That is the easy part to explain. The part I find more interesting is the road the file takes: from a laptop with no TV, emulator or Android SDK, to an address a viewer pastes into a remote-controlled screen, or to a repo that lists many of them.&lt;/p&gt;

&lt;p&gt;This post follows that road. It is built on three small things: a command-line tool, a JSON index, and a rule about published files. The opening post of this series has the bigger map; here I only care about getting a plugin out.&lt;/p&gt;

&lt;h2&gt;
  
  
  The author's loop
&lt;/h2&gt;

&lt;p&gt;The tool is &lt;code&gt;yonto-plugin&lt;/code&gt;, in the open-source plugins repo. It runs your plugin in the same QuickJS engine, with the same &lt;code&gt;yonto&lt;/code&gt; global and limits as the app, so what passes on a laptop is meant to behave the same on a television. This is the command list from the CLI's README, the part an author uses day to day (an excerpt):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node src/cli.js init   &amp;lt;id&amp;gt; [--template &amp;lt;name&amp;gt;] [--name &amp;lt;display name&amp;gt;]   a new plugin in ./&amp;lt;id&amp;gt;, from templates/&amp;lt;name&amp;gt; (blank, video-blog)
node src/cli.js lint   &amp;lt;plugin-dir&amp;gt;            manifest and bundle checks, no network
node src/cli.js run    &amp;lt;plugin-dir&amp;gt; &amp;lt;method&amp;gt; [args…]   one method, its JSON, its requests
node src/cli.js doctor &amp;lt;plugin-dir&amp;gt;            the full battery, exit code for CI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each step answers a different question.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;init&lt;/code&gt; writes a plugin that already passes the next two commands, so the whole loop is visible before you change a line.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lint&lt;/code&gt; checks the manifest against its schema, builds the file and works out which &lt;code&gt;contractVersion&lt;/code&gt; your code needs. It makes no network request.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;run&lt;/code&gt; calls one function with JSON arguments and prints its answer and the requests it made.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;doctor&lt;/code&gt; walks the plugin the way the app does: categories, a list, page two, a title from that list, a search, then the optional functions. Each step is fed by the one before, and the exit code is meant for CI.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;doctor&lt;/code&gt; has one rule I like: a successful but empty answer counts as a failure (&lt;code&gt;EMPTY_RESULT&lt;/code&gt;), because a plugin that "works" and returns nothing is otherwise silent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The manifest is a promise, in plain text
&lt;/h2&gt;

&lt;p&gt;The manifest is a comment at the top of the file, and the app reads it as text without running the file. That is why a permission lives there and not in some export. This is the header of the &lt;code&gt;blank&lt;/code&gt; template, verbatim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* yonto-plugin
{
  "kind": "content-source",
  "id": "blank",
  "name": "Blank",
  "version": "1.0.0",
  "contractVersion": 21,
  "description": "A starting point: one made-up title, and no network.",
  "provides": "source",
  "allowedHosts": []
}
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;id&lt;/code&gt; is two to 32 lowercase letters, digits and hyphens. &lt;code&gt;version&lt;/code&gt; is three numbers. &lt;code&gt;allowedHosts&lt;/code&gt; is the list of hosts the plugin may reach, and the install dialog shows it, so the manifest is what the viewer agrees to. &lt;code&gt;contractVersion&lt;/code&gt; is the newest part of the plugin interface the code uses. &lt;code&gt;lint&lt;/code&gt; computes it: declaring less is refused, and declaring more is a warning, because a number that is too high would turn away apps that could have run the plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  From a file to an address
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;bundle&lt;/code&gt; builds the publishable &lt;code&gt;dist/&amp;lt;id&amp;gt;-&amp;lt;version&amp;gt;.js&lt;/code&gt;, makes a zip containing that one file, and prints the zip's size and SHA-256. Put the zip anywhere that serves HTTPS, such as a GitHub release. A viewer then goes to Settings, Advanced, Plugins, Install from URL, pastes the address, and reads the plugin's name, version and reach before choosing Install. The app downloads a plugin file of at most 1 MiB, and the download has 30 seconds.&lt;/p&gt;

&lt;p&gt;That is enough for one plugin. For several, you make a repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  The index
&lt;/h2&gt;

&lt;p&gt;A repo is one address that lists many plugins. &lt;code&gt;yonto-plugin index plugins --base-url https://plugins.example.com&lt;/code&gt; bundles each plugin in a directory and prints a document with a &lt;code&gt;plugins&lt;/code&gt; list. Here is what it prints for a plugin with the &lt;code&gt;blank&lt;/code&gt; template's description, as a simplified sketch (the hash is shortened to a placeholder, and the host is the one from the docs):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-demo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"My demo"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"contractVersion"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"provides"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"A starting point: one made-up title, and no network."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://plugins.example.com/my-demo/my-demo-1.0.0.zip#sha256=&amp;lt;64 hex digits&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two design choices are visible in it.&lt;/p&gt;

&lt;p&gt;First, an entry has enough to list the plugin and compare versions without downloading anything: id, name, version, contract version, what it provides, a description. The index copies those from the manifest. The JSON Schema in the repo (&lt;code&gt;contracts/index.schema.json&lt;/code&gt;) requires the id, name, version, contractVersion, provides and url, and caps the list at 2000 entries, which a device refuses rather than reading part of it.&lt;/p&gt;

&lt;p&gt;Second, &lt;code&gt;url&lt;/code&gt; is the versioned zip with its hash after the &lt;code&gt;#&lt;/code&gt;, exactly the link a person could paste into Install from URL. The address says the version, and the fragment says which bytes. An entry without a hash does not match the schema's pattern, and &lt;code&gt;index --check&lt;/code&gt; refuses it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking it from the outside
&lt;/h2&gt;

&lt;p&gt;The index is data written by hand or by tool, so it gets its own check, which I think of as &lt;code&gt;doctor&lt;/code&gt; for a repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yonto-plugin index &lt;span class="nt"&gt;--check&lt;/span&gt; https://plugins.example.com/index.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It reads the document, then downloads every plugin it lists and holds each one to its entry. It refuses an entry with no hash, a download whose hash differs, and a manifest whose id, version or contract is not the one the entry states. It reports every problem it finds, not only the first. It reads the document with a reader that mirrors the app's, so what the check accepts is what a device is meant to accept.&lt;/p&gt;

&lt;p&gt;A viewer adds the repo in Settings, Advanced, Repos, Add a repo, and can Refresh it later. Removing a repo removes the sources made from it, while plugins already installed from it stay installed and stop being offered updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Published bytes do not change
&lt;/h2&gt;

&lt;p&gt;The rule I would keep even if I dropped everything else: once a version is public, the file at its address is never replaced. The repo pins each plugin by its SHA-256, so a file that changed under the same address is refused: by the app when it installs, and by &lt;code&gt;index --check&lt;/code&gt; when you test the repo. To fix a plugin you raise &lt;code&gt;version&lt;/code&gt;, bundle again and publish a new address.&lt;/p&gt;

&lt;p&gt;I like this for two reasons. A hash in the index only means something if the bytes behind it can be trusted to stay the same, and an address that names a version is easy to reason about: a new version shows up as a new number and a new address, not as a silent change under an old one.&lt;/p&gt;

&lt;p&gt;The checklist in the publishing docs ends with it: "&lt;code&gt;version&lt;/code&gt; is new."&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would take from it
&lt;/h2&gt;

&lt;p&gt;Put the manifest where it can be read without running anything, make the tool that checks it the same engine the app uses, and let an index carry a hash next to every address. Then the road from a laptop to a TV is short, and each stop on it has a command that tells you whether you are still on it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;Write a plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/publish-and-security/" rel="noopener noreferrer"&gt;Publish and security: packaging, repos and what a viewer is told&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;Test and debug: lint, run and doctor&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/plugin-reference/" rel="noopener noreferrer"&gt;Plugin reference: the manifest and the limits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/plugins-and-repos/" rel="noopener noreferrer"&gt;Plugins and repos, from the viewer's side&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The plugin SDK, CLI and public plugins on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>tooling</category>
      <category>opensource</category>
      <category>android</category>
    </item>
    <item>
      <title>From an issue to a merged PR with AI agents: plan, build, prove</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Mon, 23 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/from-an-issue-to-a-merged-pr-with-ai-agents-plan-build-prove-584l</link>
      <guid>https://dev.to/yonto/from-an-issue-to-a-merged-pr-with-ai-agents-plan-build-prove-584l</guid>
      <description>&lt;p&gt;I build Yonto Player with AI coding agents, and the part I trust most is not the typing. It is the loop around the typing: a fixed order of steps, written down once, that an agent follows for every change. I want to walk through that loop from the first look at a problem to the merge, and then show how several agents work one queue.&lt;/p&gt;

&lt;p&gt;Everything here is Markdown in the repo, and the steps use plain tools (git, the &lt;code&gt;gh&lt;/code&gt; command line, a shell and an emulator), so they are not tied to one agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  The order is the point
&lt;/h2&gt;

&lt;p&gt;The fixing workflow is seven steps: reproduce, investigate, plan, file, fix, review, merge. The skill says the order matters, and each step is there because skipping it can produce a wrong fix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Reproduce.&lt;/strong&gt; Before reading any code, see the problem happen, and see it the way a viewer hits it, in the running app, not only through a unit test. Capture it. That capture becomes the "before" in the pull request. If the problem cannot be reproduced, the agent says so and stops, because a bug that cannot be reproduced cannot be shown fixed either. A report's explanation of the cause is treated as a hypothesis to measure, not a fact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Investigate.&lt;/strong&gt; Find the cause, not the place where the symptom stops. The target is a file and line, plus a sentence on why that line produces this symptom. Where it helps, run the code instead of reading it: a throwaway test that prints what a function really returns settles in a minute what an hour of reading argues about. Then look for the same mistake nearby, and check whether the behaviour is already a recorded decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Plan.&lt;/strong&gt; Before editing, write down the cause, the change, what could break and what will not be done, and name the alternatives that were rejected. Also decide what will hold the fix, in a preferred order: a compile error, a test that fails when the fix is reverted, or a measurement in the PR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. File the issue&lt;/strong&gt;, even if the fix comes straight after. The issue is the record of what was wrong, and a PR alone does not explain itself a year later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Fix it.&lt;/strong&gt; One issue, one branch, one PR. A new test is mutated before the PR goes up: break exactly the line it claims to hold and watch it fail. A test that stays green under that is not holding anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Review&lt;/strong&gt;, by a fresh agent. &lt;strong&gt;7. Merge.&lt;/strong&gt; Those two get their own sections below.&lt;/p&gt;

&lt;h2&gt;
  
  
  An issue is a claim
&lt;/h2&gt;

&lt;p&gt;Several agents can work the same repo, each in its own working copy, and the issue is where they meet. An agent claims an issue with a comment before it starts, and it reads the existing claims first. A simplified sketch of such a comment (the real format is a convention in the repo's skill, and the names here are generic):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Claimed by agent-b.
Files: ViewModel.kt, Screen.kt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The claim names the files the work will touch, in a comment on the issue, so work does not overlap. Issues that touch the same file go to one agent together. Each agent picks its own next item, and none hands work to another. GitHub is where they meet, and the thread keeps the history for an agent that comes back later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Filing the issue
&lt;/h2&gt;

&lt;p&gt;A filed issue carries what was seen, the evidence, the cause, what should change, and a testing section that includes what must not change. It gets exactly one priority label, ranked by what a viewer loses and not by how hard the fix is. Where the fix is a judgement call and not a correction, the issue names the options and leaves the choice open.&lt;/p&gt;

&lt;h2&gt;
  
  
  The PR: why, what, how to test
&lt;/h2&gt;

&lt;p&gt;A pull request body has one job: let a reviewer decide without rebuilding my reasoning from the diff. The skill's test of a good body is that a reviewer who reads it and then the diff should find no surprises.&lt;/p&gt;

&lt;p&gt;This is a simplified sketch of its shape, with made-up details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Area: imperative summary            &amp;lt;- the title

&lt;span class="gu"&gt;## Why&lt;/span&gt;
What was wrong, in the viewer's terms: the behaviour, not the code.
Fixes #123

&lt;span class="gu"&gt;## What&lt;/span&gt;
The change, why the obvious approach was not taken, what was left alone,
and anything removed (a deleted test especially).

&lt;span class="gu"&gt;## How to test&lt;/span&gt;
&lt;span class="p"&gt;1.&lt;/span&gt; Steps in order, with the state to start from.
&lt;span class="p"&gt;2.&lt;/span&gt; Cases that must not change.
What was verified, and what was not, said plainly.

(before / after screenshots, same screen and same state)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The evidence rule is the one I like most. A change that alters what a viewer sees is not finished without a before and an after, taken on the thing itself, and for performance the evidence is numbers, measured before and after with a control. The control rows go in too, including the ones that do not help the case, because a body that shows only its best rows cannot be trusted.&lt;/p&gt;

&lt;p&gt;Before writing any of it, the agent runs the full build and test line without caches, since a cached green may not have run the tests at all. Then it asks one more question: what sentence in the docs does this change make false? It searches for every copy of that claim and fixes them in the same PR, because the docs are what the next agent reads.&lt;/p&gt;

&lt;h2&gt;
  
  
  A reviewer that did not write it
&lt;/h2&gt;

&lt;p&gt;The review goes to a fresh agent with no part in the change, one focused pass, set to a medium reasoning effort so it stays on the diff and does not turn into an audit. It is told to verify, not to read: build the branch, run the suite, run the mutations the body claims, check the body against the diff, and look at the screen if a viewer would. The reviewer has not seen the code before, but it does get a brief from the author: the two or three things they are least sure of, and a request for one thing the brief did not mention. Where one can be made, the reviewer works in its own worktree, and it changes nothing on the branch, and its verdict goes on the PR in its own words.&lt;/p&gt;

&lt;p&gt;One pass is the normal number. A second is for when the first found something worth re-checking, and two is the cap. At the cap every open point is answered in writing: the code stands and why, or it becomes its own issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merge, then keep going
&lt;/h2&gt;

&lt;p&gt;After a clean pass the author reruns the full line, compares test names against the branch's base to catch a test dropped along the way, and merges. Then it checks that the issue actually closed.&lt;/p&gt;

&lt;p&gt;The same loop, repeated, is a sweep. An agent reads its own open PRs before the issues, since finished work waiting on a reviewer beats an unstarted issue. Then it takes issues by priority label, skipping what another agent has claimed by file. Anything it notices while fixing is filed straight away and joins the queue. The sweep ends when the queue is empty, not when the first pass is done.&lt;/p&gt;

&lt;h2&gt;
  
  
  What stays with me
&lt;/h2&gt;

&lt;p&gt;The agents do not decide what to build. Where a fix is a judgement and not a correction, the skill says the call belongs to the person, so the agent states the options and asks. What the product is for, what ships, and anything that is a matter of taste stay mine. What the process buys me is that when I do read a PR, it should carry the reproduction, the cause, the evidence and a cold review, so my time goes on the decisions.&lt;/p&gt;

&lt;p&gt;If you want to try this on your own repo, two rules are a good start: reproduce the problem before touching code, and make every PR show its before and after. The rest follows from those.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/" rel="noopener noreferrer"&gt;The documentation&lt;/a&gt; for what the app does.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;The developer docs&lt;/a&gt; for the plugin contract.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;Test and debug&lt;/a&gt;, which runs a plugin on a laptop with the same engine and limits as a television.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The plugins repo&lt;/a&gt;, where the plugin tooling is open source.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>github</category>
      <category>productivity</category>
      <category>workflow</category>
    </item>
    <item>
      <title>A reviewer that did not write the code</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Sun, 22 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/a-reviewer-that-did-not-write-the-code-bbb</link>
      <guid>https://dev.to/yonto/a-reviewer-that-did-not-write-the-code-bbb</guid>
      <description>&lt;p&gt;When you write a change, you carry a lot of context that the change itself does not contain. You know what you meant, what you tried first, which case you were thinking of and which you were not. Reading your own diff back, your head fills in the gaps, so the diff looks complete.&lt;/p&gt;

&lt;p&gt;A reader who arrives cold has none of that. They have the pull request body, the diff and the code around it, and where those disagree they notice. That is the whole idea behind how I review changes in Yonto Player, which I build with AI coding agents: the review goes to a fresh agent that had no part in writing the change.&lt;/p&gt;

&lt;p&gt;This post is about the setup, not about any one review.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why "fresh" is the point
&lt;/h2&gt;

&lt;p&gt;An agent that wrote the change, or that argued the approach into shape with me, shares the author's assumptions. Our rules say it directly: having decided what a change should say is authoring, not reviewing, however little of it you typed. Agreeing with a change in conversation is not a verdict either.&lt;/p&gt;

&lt;p&gt;So the rule is that a verdict comes from somebody who came to the change cold. That is true for code and for docs alike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four pieces
&lt;/h2&gt;

&lt;p&gt;The setup is small. It is four things in the repo, and none of them is clever.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. An agent definition file.&lt;/strong&gt; The repo has one file that defines a single agent, called &lt;code&gt;reviewer&lt;/code&gt;. Many tools that let you define agents also let you pin settings such as the reasoning effort, so this part of the advice depends on your tool. The file is a few lines: a name, a description of when to use it, an effort setting, and a short brief. A simplified sketch of its shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;reviewer&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Reviews&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;one&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;PR&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;as&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;fresh&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;worker&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;with&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;no&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;part&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;in&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;writing&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;it."&lt;/span&gt;
  &lt;span class="s"&gt;Use for every review pass the workflow asks for.&lt;/span&gt;
&lt;span class="na"&gt;effort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;medium&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;

You are reviewing one pull request, and you had no part in writing it.
Read the review constraints before anything else; they are yours,
and the brief you were given can add to them but never relax them.
Verify rather than read, stay scoped to the diff and the body's own
claims, and post the verdict on the PR.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter. The first is the effort setting. A plain subagent inherits the effort of whoever starts it, so a review launched from a long, deliberate session would run at that level too. Pinning it in the definition gives every review the same reasoning budget, while the scoping rules below keep each one a single focused pass. The second is that the brief points at one shared set of constraints instead of repeating them, so there is one place that says what a reviewer may and may not do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. A skill that asks for it by name.&lt;/strong&gt; The repo's workflows are Markdown files any agent can follow. The skills for fixing an issue and for working a queue of issues both have a step that delegates the review to a fresh worker, and &lt;code&gt;AGENTS.md&lt;/code&gt; says that when a skill asks for one, you spawn the &lt;code&gt;reviewer&lt;/code&gt; agent. The skill for opening a pull request points at the same protocol: verify rather than read, two passes at most. The skill does not describe how to be a reviewer. It names the agent, and the agent's definition does the rest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. A cap.&lt;/strong&gt; One pass is the normal number. A second pass is for when the first found something that needed fixing and the fix is worth a look. Two is a hard cap. At the cap, every point still open is settled in writing: either the code stands and here is why, or the point is real and becomes its own issue. There is no third loop. Without a cap, review turns into a conversation that ends when somebody gets tired; with one, it ends because there is a rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. A rule about what a review is.&lt;/strong&gt; A review is one focused pass at medium effort, scoped to the diff and to what the pull request body claims about it. Build the branch, run the tests, run the checks the body names, compare the body with the diff, and look at the screen if a viewer would see it. The reviewer posts its own verdict as a review on the pull request, with its findings as inline comments, and it changes nothing on the branch. If it wants something fixed, that is a finding, and the author makes the fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it is given, and what it is not
&lt;/h2&gt;

&lt;p&gt;A reviewer that is told only "review this" will read the diff and nod. So the author's brief has a few jobs.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Say what you are least sure of.&lt;/strong&gt; Naming two or three things keeps the pass focused. A reviewer with no steer ends up auditing everything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name what would have to be true for the change to be right.&lt;/strong&gt; The reviewer then meets a claim to check, not a design to accept.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask for one thing the brief did not mention&lt;/strong&gt;, or a plain statement that it found none. An author who lists the checks hands over the failures they already thought of.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Let the reviewer substitute its own inputs&lt;/strong&gt; where a result depends on ordering or hashing. Re-running the author's checks on the author's examples only confirms the author's frame.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And there is a list of things it is deliberately not asked to do: re-derive facts about the repo that the diff does not touch, fact-check claims that are not load-bearing, re-measure what the author already measured, or sweep the codebase for the same pattern elsewhere. That last one is a good idea and a separate task, so it gets filed as its own issue instead of being folded into the review.&lt;/p&gt;

&lt;p&gt;The brief can add to the reviewer's constraints, but it can never take anything out of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What comes back, and what happens to it
&lt;/h2&gt;

&lt;p&gt;The repo's rule for what comes back is short: the review's body opens with a &lt;code&gt;Verdict:&lt;/code&gt; line, and the findings are inline comments on the lines they are about. A format that works well for a finding, though it is my suggestion and not the repo's rule, is a few plain lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Verdict: &amp;lt;one line&amp;gt;

path/to/file:42  what I ran, what I saw, and why it matters
Claims in the PR body the diff does not back up: &amp;lt;list, or none&amp;gt;
One thing the brief did not mention: &amp;lt;it, or "found none"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The author's side has its own rule, and it is short: every finding is fixed or answered. A real finding is fixed in the same pull request, with a test of its own. A finding the author disagrees with gets an answer in writing, with the reason. Nothing is dropped silently. A defect that the fix itself introduces is still the author's.&lt;/p&gt;

&lt;p&gt;There is one more line, and it is a discipline, not a mechanism: the author never writes a "Verdict:" line about their own work. The verdict is the reviewer's, posted by the reviewer, and the author's account of what they fixed goes in as a separate comment. Merging checks that a verdict is there before anything else.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I would take from this
&lt;/h2&gt;

&lt;p&gt;You do not need this exact repo to borrow the shape.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define the reviewer once, in a file, and pin its effort if your tool lets you.&lt;/li&gt;
&lt;li&gt;Have your workflows name it instead of describing it.&lt;/li&gt;
&lt;li&gt;Give it a brief that says what you are unsure of, and ask for the thing you did not think of.&lt;/li&gt;
&lt;li&gt;Cap the passes and settle everything open in writing at the cap.&lt;/li&gt;
&lt;li&gt;Fix every finding or answer it.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;The developer docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;Testing and debugging a plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/" rel="noopener noreferrer"&gt;The documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The plugin SDK and public plugins on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/changelog/" rel="noopener noreferrer"&gt;The changelog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>codereview</category>
      <category>productivity</category>
      <category>android</category>
    </item>
    <item>
      <title>Our repo's workflows are Markdown files any agent can run</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Sat, 21 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/our-repos-workflows-are-markdown-files-any-agent-can-run-3754</link>
      <guid>https://dev.to/yonto/our-repos-workflows-are-markdown-files-any-agent-can-run-3754</guid>
      <description>&lt;p&gt;Yonto Player is a media player for your own library on Android TV, phones and tablets. Its repo keeps its workflows as Markdown files that any AI coding agent, or a person, can follow. This post shows what that means in practice, because the format is small enough to copy.&lt;/p&gt;

&lt;p&gt;The repo has a &lt;code&gt;skills/&lt;/code&gt; directory with seven folders. Each holds one file, &lt;code&gt;SKILL.md&lt;/code&gt;, and two of them add a &lt;code&gt;references/&lt;/code&gt; folder. There is one for a quality round, one for filing an issue, one for sweeping the issue queue, one for fixing a single issue, one for opening a pull request, one for a walkthrough of the app as a viewer, and one for writing a source plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of a skill
&lt;/h2&gt;

&lt;p&gt;A skill has two parts. At the top is front matter with a &lt;code&gt;name&lt;/code&gt; and a &lt;code&gt;description&lt;/code&gt;. Below it is the body, which is prose and shell commands in the order you would do them.&lt;/p&gt;

&lt;p&gt;Here is a simplified sketch with generic content, not a file from the repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ship-a-change&lt;/span&gt;
&lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;&amp;gt;"&lt;/span&gt;
  &lt;span class="na"&gt;Use when a change is ready to propose&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;open&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;a&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;PR"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;put&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;this&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;up"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/ship-a-change". Produces a PR whose body says why, what and how to test.&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;

&lt;span class="gh"&gt;# Ship a change&lt;/span&gt;

One sentence on what a good result looks like.

&lt;span class="gu"&gt;## Before you write anything&lt;/span&gt;

(commands to run, in order, each with the reason it is there)

&lt;span class="gu"&gt;## The body&lt;/span&gt;

(what the three sections hold, and the test of a good one)

&lt;span class="gu"&gt;## Then&lt;/span&gt;

(what comes next, and which other skill covers it)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is nearly all there is to it. There is no schema beyond those two fields, no code and no registry. A person can read the file top to bottom and follow it, and an agent can be pointed at the same file.&lt;/p&gt;

&lt;h2&gt;
  
  
  The description is the trigger
&lt;/h2&gt;

&lt;p&gt;The part to get right is the &lt;code&gt;description&lt;/code&gt;. The description is what tells an agent when to use the skill.&lt;/p&gt;

&lt;p&gt;Most descriptions in this repo start with "Use when" or "Use to", and they share three parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The situation&lt;/strong&gt;, in the words someone would actually say: "open a PR", "fix an issue", "do a quality round".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The slash-style name&lt;/strong&gt; in quotes, so an agent that is told to run a skill by name finds the same file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it covers or produces&lt;/strong&gt;, so two neighbouring skills do not both claim one job.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last part matters more than it looks. Filing an issue and fixing an issue are different jobs, and fixing one &lt;em&gt;includes&lt;/em&gt; filing it. The fix skill says so in its description, and then points at the filing skill by name instead of repeating its rules. Skills refer to each other by name, which keeps each rule in one place.&lt;/p&gt;

&lt;h2&gt;
  
  
  No particular agent is assumed
&lt;/h2&gt;

&lt;p&gt;The skills are written so that an assistant with a skill mechanism, one that only reads files, or a person can run them. They do not rely on a particular AI agent product or on a feature only one of them has. The steps use ordinary developer tools: git, &lt;code&gt;gh&lt;/code&gt;, a shell and, for work on the app, an emulator.&lt;/p&gt;

&lt;p&gt;Where a step needs something an agent may not offer, the skill says what has to happen and what to do if you cannot do it that way. The review step is the clearest example. The fix and sweep workflows end in a review by a fresh worker that had no part in writing the change. The skills say to use a helper where the agent provides one, and otherwise a separate session. The point is the independence of the reviewer, and a helper is only one way to get it.&lt;/p&gt;

&lt;p&gt;The skills' README also says where they live. The repo keeps a directory of relative symlinks for assistants that discover skills by a directory convention, so there is one copy of each skill to keep up to date. If another tool expects its own folder, the answer is another symlink.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps, in prose and shell
&lt;/h2&gt;

&lt;p&gt;The bodies are written as instructions, not as documentation. Most of the skills put commands in fenced blocks you can copy. The reasoning sits next to them in a sentence.&lt;/p&gt;

&lt;p&gt;A few patterns repeat across the seven:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Order is part of the content.&lt;/strong&gt; The fix skill is seven numbered steps: reproduce, investigate, plan, file, fix, review, merge. If you cannot reproduce a problem, it says to say so and stop, rather than fix by inference.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A good result is defined first.&lt;/strong&gt; The pull request skill opens with a test for a good body: a reviewer who reads it and then reads the diff should find no surprises.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence is part of the job.&lt;/strong&gt; The quality round says to take a screenshot after every step and to verify a finding before filing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The queue has an order.&lt;/strong&gt; The sweep skill says to read the pull request list before the issue list. It ends when the queue is empty, not when the first pass is done.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Supporting material goes under references/
&lt;/h2&gt;

&lt;p&gt;The quality round and the sweep are long, and most of their detail only matters at one step. So the main file stays short and points at a &lt;code&gt;references/&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;The quality round keeps two files there: a list of what a round walks, and a set of techniques for reaching states a happy path never visits, such as offline or a stream that never starts. The sweep keeps its rules for several working copies in one &lt;code&gt;coordination.md&lt;/code&gt;. They claim an issue in a comment, each picks its own next issue, and none assigns work to another.&lt;/p&gt;

&lt;p&gt;An agent that is only fixing a bug usually does not need to read any of that, so it spends no context on it. This is the same idea as the read-this-when table in &lt;code&gt;AGENTS.md&lt;/code&gt;, applied to workflows: the entry point is small and says where the depth is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs change with the code
&lt;/h2&gt;

&lt;p&gt;One rule sits above every skill, and the skills' README states it first: a change to the docs, &lt;code&gt;AGENTS.md&lt;/code&gt; or a skill happens in the same pull request as the code it describes. The pull request skill has a step for it. It asks what the change makes false, then asks you to search for the subject, not the sentence, and read every hit. Skills describe commands and file paths that have to stay true, so they get the same treatment as code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you can take from this
&lt;/h2&gt;

&lt;p&gt;If you want to try it in your own repo:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Pick a job you repeat, and write the steps as you would explain them to a new teammate.&lt;/li&gt;
&lt;li&gt;Put a &lt;code&gt;name&lt;/code&gt; and a &lt;code&gt;description&lt;/code&gt; in front matter, and write the description as the situation someone would say out loud.&lt;/li&gt;
&lt;li&gt;Keep the file short, and move detail that only one step needs into &lt;code&gt;references/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Where a step needs a helper, such as a second reviewer, say what to do when you do not have one.&lt;/li&gt;
&lt;li&gt;When one job includes another, point at the other skill by name instead of copying its rules.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;developer docs&lt;/a&gt; describe the plugin contract that the plugin skill points at, and &lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;test and debug&lt;/a&gt; covers running a plugin without a device. The plugin SDK, command-line tool and public plugins are in &lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;the plugins repo&lt;/a&gt;. The &lt;a href="https://player.yonto.app/docs/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; and the &lt;a href="https://player.yonto.app/changelog/" rel="noopener noreferrer"&gt;changelog&lt;/a&gt; cover the rest.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>documentation</category>
    </item>
    <item>
      <title>How a large repo keeps its docs true: the standing rule</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Fri, 20 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/how-a-large-repo-keeps-its-docs-true-the-standing-rule-234c</link>
      <guid>https://dev.to/yonto/how-a-large-repo-keeps-its-docs-true-the-standing-rule-234c</guid>
      <description>&lt;p&gt;In a repo worked on by AI coding agents, the docs have an unusual reader. Each new session starts cold, reads &lt;code&gt;AGENTS.md&lt;/code&gt;, the design notes and the skills, and then builds on what it read. So a doc is not only for people: it is input to the next piece of code, and a wrong sentence in it becomes a wrong assumption in new work.&lt;/p&gt;

&lt;p&gt;Yonto Player's repo has one rule for this, at the top of &lt;code&gt;AGENTS.md&lt;/code&gt;: &lt;strong&gt;docs change in the same pull request as the code, never as a follow-up.&lt;/strong&gt; This post is about the rule and the small habits around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rule
&lt;/h2&gt;

&lt;p&gt;The wording in the repo is short. &lt;code&gt;docs/&lt;/code&gt;, &lt;code&gt;AGENTS.md&lt;/code&gt; and &lt;code&gt;skills/&lt;/code&gt; are what the next session reads, so a change whose docs are not written is unfinished.&lt;/p&gt;

&lt;p&gt;"Unfinished" is the useful word. A follow-up PR for docs is a promise that no build checks. If the docs are part of the definition of done, the reviewer sees the code and the prose it changes in one diff, and "did the docs change?" has an answer on the page.&lt;/p&gt;

&lt;p&gt;The scope is deliberate. You update the docs that the change invalidates, and you find them by searching the subject across the whole repo. The aim is not to polish documentation, it is to keep it describing what the code does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Name the sentence the change makes false
&lt;/h2&gt;

&lt;p&gt;The PR skill in the repo (&lt;code&gt;skills/open-a-pr&lt;/code&gt;) adds a step before you write the description. In my words: state in one sentence what this change makes false, then find every copy of that sentence.&lt;/p&gt;

&lt;p&gt;The skill spells out the method:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Search for the subject, not the wording.&lt;/strong&gt; You cannot guess how someone else phrased a claim, so search for the thing the claim is about, using a few generic words for it, and read every hit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the file you edited first.&lt;/strong&gt; It is the place you were already writing in, and the easiest to check.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change every copy.&lt;/strong&gt; If a claim lived in two files, both change in the same PR, so the docs agree with each other.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check a correction the same way.&lt;/strong&gt; The new sentence asserts something too, so search for its subject with the same care.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Replace, don't append.&lt;/strong&gt; Rewrite the old sentence instead of adding the right one beside it, so the page holds one answer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a simplified sketch of that step as a checklist, not the repo's exact text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before opening the PR
  1. Write one sentence: "This change makes ___ false."
  2. Pick the SUBJECT of that sentence (a feature, a name, a limit),
     not its wording.
  3. grep -rn "&amp;lt;subject&amp;gt;" docs/ AGENTS.md skills/ README.md site/ &amp;lt;source dirs&amp;gt;
  4. Read every hit. Start with the file you edited.
  5. Update each copy in place. Then search for what your new text asserts.
  6. Ask: is there a sentence anywhere this change contradicts?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is a habit made explicit, so an agent follows it the same way each time. Prose has no test suite of its own, so this search is the check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Annotate a dated record, rewrite a live claim
&lt;/h2&gt;

&lt;p&gt;The repo has two kinds of docs, and they are treated differently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Live claims&lt;/strong&gt; say how things are now: &lt;code&gt;AGENTS.md&lt;/code&gt;, a docblock, the pages on the site. They are rewritten in place to say what is true today.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dated records&lt;/strong&gt; say what was decided and why, on a particular day. &lt;code&gt;docs/design/&lt;/code&gt; holds close to sixty of them, each named with its date. A record like that is history, and its value is that it still says what it said that day. So a later change adds a dated note to it and says what superseded the line, instead of editing the original.&lt;/p&gt;

&lt;p&gt;A simplified sketch of the shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Decisions (2026-10-24, #NNNN)&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Feature X reads its limit from the server.

&lt;span class="gu"&gt;### Added 2026-10-29 (#MMMM)&lt;/span&gt;
&lt;span class="p"&gt;
-&lt;/span&gt; Feature X also shows the limit on the settings page.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reader sees the original reasoning, then what was added and when. A live page that mentions the feature is rewritten to describe the current behaviour only.&lt;/p&gt;

&lt;h2&gt;
  
  
  Docs that a test or a build checks
&lt;/h2&gt;

&lt;p&gt;Where a doc can be checked by a machine, it can be.&lt;/p&gt;

&lt;p&gt;The developer guide on the site has a tutorial that walks through a small plugin. Its code blocks are copied from the plugin template in the CLI, and a test compares the page to the template, once for each language the page exists in. Change one without the other and the suite goes red.&lt;/p&gt;

&lt;p&gt;The site build also checks pages. A page-metadata check fails the build when a page has no title or description, shares a title with another page, has an incomplete set of language alternates, is missing from the sitemap, or carries structured data that does not parse. It runs as part of &lt;code&gt;npm run build&lt;/code&gt;, so for the properties the checks cover, a page that breaks them does not get as far as a deploy.&lt;/p&gt;

&lt;p&gt;The principle is the same one as for code: if a property of the docs matters, write it down as something that can fail. What a build cannot check, such as whether a screen is called "Add source", is covered by the rule that the site's docs use the app's own words and change in the same PR as the strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  The docs map
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;AGENTS.md&lt;/code&gt; is a briefing: the layout, the build line, the rules, and a table of "read this when" entries that point to the deep-dives in &lt;code&gt;docs/agents/&lt;/code&gt;. Where it can, the repo keeps the detail in the deep-dive that owns it and points to it from the front page. Fewer copies of a claim means fewer sentences to search for when something changes, though some claims do live in more than one place, which is what the subject search is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you can take from it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Make docs part of "done", in the same PR as the code.&lt;/li&gt;
&lt;li&gt;Before you open the PR, name the one sentence the change makes false.&lt;/li&gt;
&lt;li&gt;Search for the subject, not the wording, and read every hit, starting with your own file.&lt;/li&gt;
&lt;li&gt;Rewrite live claims in place, and add dated notes to dated records.&lt;/li&gt;
&lt;li&gt;Where a doc can be checked by a test or a build, check it there.&lt;/li&gt;
&lt;li&gt;Prefer one home for each fact, and point to it from the others.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The next session then starts from something true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;The developer docs for plugin authors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/troubleshooting/" rel="noopener noreferrer"&gt;Troubleshooting, which quotes the app's own error sentences&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/plugins-and-repos/" rel="noopener noreferrer"&gt;Plugins and repos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The public plugin repository, with the CLI&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>documentation</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Tests that prove something: break a copy and see the test fail</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Thu, 19 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/tests-that-prove-something-break-a-copy-and-see-the-test-fail-16eg</link>
      <guid>https://dev.to/yonto/tests-that-prove-something-break-a-copy-and-see-the-test-fail-16eg</guid>
      <description>&lt;p&gt;A green suite only counts if it can go red. So when a test is written for a fix, the practice in Yonto Player's repo is to revert the fix and watch that test fail, and to break the exact line the test claims to hold. This post is how that loop works, how to run it safely, and what to do with fakes so the loop is cheap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two questions, both answered by failing
&lt;/h2&gt;

&lt;p&gt;There are two claims a change can make, and each has its own proof.&lt;/p&gt;

&lt;p&gt;The first is "this fixes a behaviour". The proof is a test that fails without the fix. The repo's fix workflow ranks the ways to hold a fix in order: a compile error, then a test that fails when the fix is reverted, then a measurement in the PR body for something the harness cannot assert. Where the shape allows it, the test is written first and watched failing for the right reason, then the fix turns it green.&lt;/p&gt;

&lt;p&gt;The second is "this rule holds". The proof is a mutation: change the code in the one way that breaks the rule, and a test has to go red. If nothing does, that is information too, and there are a few readings of it, covered below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mutate one decision at a time
&lt;/h2&gt;

&lt;p&gt;The repo's testing notes are specific about how to mutate, because a careless mutation proves less than it looks like.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Revert one site and one decision at a time.&lt;/strong&gt; A combined revert going red proves something is pinned, but never that everything is. If a change has three decisions, each gets its own revert and its own named test.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Revert the connection as well as the logic.&lt;/strong&gt; The &lt;code&gt;CompositionLocalProvider&lt;/code&gt;, the callback a screen is handed, the argument at the one call site: these look like plumbing, and they are the lines most easily left unpinned. Where the connection is a parameter, drop its default. A compile error saying no value was passed for the parameter is proof that cannot rot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;For a guard over a sequence, break the member that makes the proof hardest.&lt;/strong&gt; Break the last item of a loop, not the first. If the run stops at the first item, "nothing before it was affected" is a fact about ordering, not about your code. Then break two and check that the failure reports both.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When a mutation survives, read it four ways.&lt;/strong&gt; The line may be untested (add a test). It may change nothing the function returns for any input (delete it). It may change the result in a way today's only caller cannot see (test the function directly). Or the fixture may not be able to tell the difference (change the fixture).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  An example you can check
&lt;/h2&gt;

&lt;p&gt;Here is a real shape from the codebase, as a simplified sketch. A small cache keeps an answer for a time-to-live, and takes its clock as a constructor parameter, defaulting to the system clock.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch, not the real file.&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ExpiringCache&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;K&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;V&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;ttlMillis&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;clock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;nowMillis&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="c1"&gt;// inside get(): a cached entry is fresh while&lt;/span&gt;
    &lt;span class="c1"&gt;//   clock() - entry.loadedAt &amp;lt; ttlMillis&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the shape of the tests, with the clock as a plain variable the test owns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the tests.&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;now&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1_000_000L&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;cache&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ExpiringCache&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;ttlMillis&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5_000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clock&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nd"&gt;@Test&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;`a&lt;/span&gt; &lt;span class="n"&gt;fresh&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;answered&lt;/span&gt; &lt;span class="n"&gt;without&lt;/span&gt; &lt;span class="n"&gt;loading&lt;/span&gt; &lt;span class="nf"&gt;again`&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;runTest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;4_999&lt;/span&gt;
    &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;@Test&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;`an&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="n"&gt;older&lt;/span&gt; &lt;span class="n"&gt;than&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nf"&gt;reloaded`&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;runTest&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;5_000&lt;/span&gt;
    &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;assertEquals&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pair sits on both sides of the boundary, 4,999 and 5,000. That is the point of the mutation: change &lt;code&gt;&amp;lt;&lt;/code&gt; to &lt;code&gt;&amp;lt;=&lt;/code&gt; in the freshness check and the entry counts as fresh at exactly 5,000, so the second test sees one load instead of two and goes red. A suite with only the first test would stay green through that mutation.&lt;/p&gt;

&lt;p&gt;An injected clock is what makes this possible at all. Time is a parameter, so the test moves it by hand: no sleeping and no waiting for a real five seconds, so the clock cannot make the test flaky.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do it on a copy
&lt;/h2&gt;

&lt;p&gt;A mutation is a deliberately broken version of your code, so it never belongs in the tree you are working in. The safe loop is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Simplified sketch of the loop. All paths and names are generic placeholders.&lt;/span&gt;
&lt;span class="nv"&gt;COPY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$SCRATCH&lt;/span&gt;/mutation-copy
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$COPY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$REPO&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$COPY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;      &lt;span class="c"&gt;# the real tree is never touched&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$COPY&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; build/test-results/test/&lt;span class="k"&gt;*&lt;/span&gt;.xml           &lt;span class="c"&gt;# no old result can answer for this run&lt;/span&gt;

perl &lt;span class="nt"&gt;-pi&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'s/&amp;lt; ttlMillis/&amp;lt;= ttlMillis/'&lt;/span&gt; src/Cache.kt
git diff &lt;span class="nt"&gt;--quiet&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; src/Cache.kt &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"mutation did not apply"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;

./gradlew &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--tests&lt;/span&gt; &lt;span class="s1"&gt;'*CacheTest'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;   &lt;span class="c"&gt;# a red run is the point&lt;/span&gt;

&lt;span class="nb"&gt;ls &lt;/span&gt;build/test-results/test/&lt;span class="k"&gt;*&lt;/span&gt;.xml &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"no tests ran"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;failure'&lt;/span&gt; build/test-results/test/&lt;span class="k"&gt;*&lt;/span&gt;.xml   &lt;span class="c"&gt;# lists result files holding a failure; open one to see which test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details matter more than the rest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Work on a copy.&lt;/strong&gt; The real tree stays exactly as you left it, and throwing the copy away is the whole cleanup. There is no step that restores anything, so there is nothing to forget.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check that the mutation applied.&lt;/strong&gt; A scripted replace that matches nothing is a silent no-op, and the run that follows is then an unmutated run. Assert that the diff is not empty before you read anything into the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check that tests ran before counting failures.&lt;/strong&gt; Zero failures from zero tests also reads as green. So the repo's notes say to delete the test's result files before the run and check that they exist afterwards, The same habit covers a rebase or a conflict in a test file: compare the test names against where you came from, because counting &lt;code&gt;@Test&lt;/code&gt; annotations misses a removal netted against an addition.&lt;/p&gt;

&lt;h2&gt;
  
  
  What fakes are for
&lt;/h2&gt;

&lt;p&gt;A fake is the other half of this practice. A real source or a real clock makes a mutation round slow and noisy, and a fake makes it fast and exact.&lt;/p&gt;

&lt;p&gt;The repo has a fake content source with call counters, so a test can assert that a second screen load did not ask the source again. It also has gates: a category or a detail call can be held until the test completes a deferred, which lets a test assert what is on screen while a call is still in flight. That matters because a state flow conflates values, so "it never went blank" cannot be asserted by collecting; you hold the call and look while it is held.&lt;/p&gt;

&lt;p&gt;One caution from the same notes: a gated fake reads its answer after its gate opens, so set an older answer back before opening the gate.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a red test does not tell you
&lt;/h2&gt;

&lt;p&gt;A green mutation round is evidence that a test is not vacuous. It is not evidence that the thing works. Mutation shows a test notices a change in the code; it cannot notice what the harness makes impossible. A bug that depends on the order of UI frames cannot show up under a test dispatcher that runs launched work eagerly, so breaking the line still turns the test red while saying nothing about a television. Claims about frame ordering, timing and what is on screen when are settled on a device, and a scripted smoke test covers the basics of starting, reaching Home, finding a title and playing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Pick the last test you wrote. Make a copy of the project, break the one line it claims to hold, confirm the mutation applied, run it with the old results deleted, and check which test went red. If none did, you have found out something the green suite could not tell you.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;Test and debug a plugin&lt;/a&gt;: linting, running and recording a plugin on your computer, and writing tests for it.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;Write a plugin&lt;/a&gt;: the plugin developer docs.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The plugin SDK and CLI&lt;/a&gt;: open source, including the CLI's tests.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>testing</category>
      <category>kotlin</category>
      <category>android</category>
      <category>programming</category>
    </item>
    <item>
      <title>Dolby Vision profile 5 on Android without a Dolby Vision decoder</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Thu, 19 Nov 2026 08:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/dolby-vision-profile-5-on-android-without-a-dolby-vision-decoder-2eb5</link>
      <guid>https://dev.to/yonto/dolby-vision-profile-5-on-android-without-a-dolby-vision-decoder-2eb5</guid>
      <description>&lt;p&gt;Dolby Vision profile 5 is common, and on an Android TV box or phone without a Dolby Vision decoder it plays green and purple. Here is how Yonto Player draws them with the right colours anyway, on top of media3 (ExoPlayer), with the GPU doing the colour work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why profile 5 is the hard one
&lt;/h2&gt;

&lt;p&gt;Profile 8 carries an HDR10, HLG or SDR picture under the Dolby Vision layer, so a device that knows nothing about Dolby Vision can still show something sensible. Profile 5 has no such fallback. The picture is coded in Dolby's own IPT-PQ-c2 colour space, and every frame carries an RPU (Reference Processing Unit) with the metadata that turns it back into light. Skip the RPU and decode it as plain HEVC, and you are looking at IPT values as if they were YCbCr, which is where the green and purple come from.&lt;/p&gt;

&lt;p&gt;media3 maps Dolby Vision profiles 4, 8 and 9 to an HEVC decoder when no Dolby Vision decoder is present. Profile 5 it leaves alone, which makes sense, since there is no base layer to show. So on most phones and many TV boxes it finds no decoder at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  The plan
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;If the device has a Dolby Vision decoder, use it, as before.&lt;/li&gt;
&lt;li&gt;Otherwise decode the track as HEVC Main 10.&lt;/li&gt;
&lt;li&gt;Read each frame's RPU on its way into the decoder.&lt;/li&gt;
&lt;li&gt;Have the decoder render into a &lt;code&gt;SurfaceTexture&lt;/code&gt; instead of the screen.&lt;/li&gt;
&lt;li&gt;Apply the RPU on the GPU, tone-map to SDR, and draw to the screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Choosing the decoder
&lt;/h3&gt;

&lt;p&gt;The video renderer is media3's &lt;code&gt;MediaCodecVideoRenderer&lt;/code&gt; with &lt;code&gt;getDecoderInfos&lt;/code&gt; overridden. media3's own choice comes first, so a real Dolby Vision decoder always wins. Only when that list is empty and the track is profile 5 (codecs &lt;code&gt;dvhe.05&lt;/code&gt; or &lt;code&gt;dvh1.05&lt;/code&gt;) does it fall back to the plain HEVC decoders, keeping only those whose capabilities list the Main 10 profile (or list nothing, which some decoders do).&lt;/p&gt;

&lt;p&gt;The codec is then configured as HEVC with &lt;code&gt;KEY_PROFILE&lt;/code&gt; set to Main 10.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading the RPU
&lt;/h3&gt;

&lt;p&gt;The RPU travels as an HEVC NAL unit of type 62, whose two-byte header is &lt;code&gt;7C 01&lt;/code&gt;. In &lt;code&gt;onQueueInputBuffer&lt;/code&gt; the renderer looks at each access unit just before it goes to the decoder, finds the last RPU in it from the end, strips the emulation-prevention bytes, checks its CRC-32 and parses it. The parser is plain Kotlin in the shared core, since nothing in it is Android's.&lt;/p&gt;

&lt;p&gt;Two things make this harder than it sounds. B-frames come out of the decoder in a different order than they went in, so the parsed RPU is stored against the sample's timestamp and taken back out by presentation time when the decoder releases that frame. And RPUs refer back to earlier ones: a reshaping can be reused by id, and display metadata can be left out to mean "same as before", so they are resolved in decode order. A missing or broken RPU reuses the previous frame's, and a seek forgets all of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Drawing it ourselves
&lt;/h3&gt;

&lt;p&gt;The renderer keeps the screen's &lt;code&gt;Surface&lt;/code&gt; it receives through &lt;code&gt;MSG_SET_VIDEO_OUTPUT&lt;/code&gt; for itself and hands the codec the input &lt;code&gt;Surface&lt;/code&gt; of a &lt;code&gt;SurfaceTexture&lt;/code&gt;. For each frame it releases, it tells the drawing side the release time and the RPU that goes with it. The drawing side renders, sets that time with &lt;code&gt;eglPresentationTimeANDROID&lt;/code&gt; and swaps. Frame pacing and A/V sync stay media3's.&lt;/p&gt;

&lt;h3&gt;
  
  
  The one extension that makes it possible
&lt;/h3&gt;

&lt;p&gt;This was the crux. Sampling an external texture with &lt;code&gt;samplerExternalOES&lt;/code&gt; gets you RGB: the driver converts from YCbCr and clamps, and the IPT codes are gone before your shader sees them. &lt;code&gt;GL_EXT_YUV_target&lt;/code&gt; adds &lt;code&gt;__samplerExternal2DY2YEXT&lt;/code&gt;, which hands you the raw Y, U and V codes instead. Declaring it is all the extension asks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight glsl"&gt;&lt;code&gt;&lt;span class="cp"&gt;#extension GL_EXT_YUV_target : require&lt;/span&gt;
&lt;span class="n"&gt;uniform&lt;/span&gt; &lt;span class="n"&gt;__samplerExternal2DY2YEXT&lt;/span&gt; &lt;span class="n"&gt;frame&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// texture(frame, uv) returns Y, U, V codes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The shader then looks those codes up in a table (below) and writes RGB.&lt;/p&gt;

&lt;p&gt;No OpenGL ES 3, no &lt;code&gt;GL_EXT_YUV_target&lt;/code&gt;, or no HEVC decoder with Main 10, and the whole path is off. Those devices play it in the app's second player, which says its colours won't be right. &lt;a href="https://dev.to/yonto/two-video-players-in-one-app-and-the-rule-that-picks-one-4ff7"&gt;Two video players in one app, and the rule that picks one&lt;/a&gt; covers that hand-over.&lt;/p&gt;

&lt;h2&gt;
  
  
  The colour maths
&lt;/h2&gt;

&lt;p&gt;In order, per pixel:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The RPU's reshaping curves (polynomial and MMR pieces) bring I, P and T back.&lt;/li&gt;
&lt;li&gt;The RPU's matrix and offset take IPT to PQ-coded LMS.&lt;/li&gt;
&lt;li&gt;The PQ curve turns that into linear light.&lt;/li&gt;
&lt;li&gt;LMS to BT.2020.&lt;/li&gt;
&lt;li&gt;ITU-R BT.2390's tone map on the brightest channel, from the scene's peak (the RPU's level 1 metadata, else the mastering display's peak, never below 100 nits) down to SDR white at 203 nits.&lt;/li&gt;
&lt;li&gt;BT.2020 to BT.709, clipped.&lt;/li&gt;
&lt;li&gt;The sRGB curve.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is written from the published standards and the bitstream syntax.&lt;/p&gt;

&lt;h2&gt;
  
  
  Too slow per pixel, so bake it
&lt;/h2&gt;

&lt;p&gt;Run in full for every pixel, that took 80 ms for one 1080p frame on a Google TV Streamer's PowerVR GE9215. A 24 fps film needs a frame every 42 ms.&lt;/p&gt;

&lt;p&gt;So the maths runs once into a 3D lookup table and every frame is one texture fetch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;65 × 65 × 65 points, 10 bits a channel (&lt;code&gt;GL_RGB10_A2&lt;/code&gt;, which every OpenGL ES 3.0 device can render into and filter).&lt;/li&gt;
&lt;li&gt;Rebuilt one layer at a time, only when a frame's parameters differ from the last one's, which in practice means at a scene change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Against the exact maths over every pixel of two frames, the table is within 0.13 of an 8-bit level on average, with under 0.5% of channels more than two levels off, the worst at the edge of the gamut. Spacing the table's points towards the shadows measured no better, since the error is at the gamut's edge, not in the steep start of the curve.&lt;/p&gt;

&lt;h2&gt;
  
  
  How close it gets
&lt;/h2&gt;

&lt;p&gt;On the Google TV Streamer, with its own Dolby Vision decoder hidden from the renderer so the HEVC decoder and the GPU did the work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frame 48 of the 1080p sample: within 0.5 of a level of the reference implementation on average (worst 9).&lt;/li&gt;
&lt;li&gt;Frame 300, after seeking into another scene: within 0.8 on average (worst 23, with 0.03% of pixels more than 8 off).&lt;/li&gt;
&lt;li&gt;No dropped frames at 1080p, or at 4K at 25 fps.&lt;/li&gt;
&lt;li&gt;Moving the picture to a new &lt;code&gt;Surface&lt;/code&gt; mid-play works.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For comparison, libplacebo through FFmpeg (on MoltenVK, with BT.2390 chosen) lands within 3.1 and 4.5 levels of ours on the same two frames, about as far as it is from the reference (3.0 and 4.3). Its knee and black point differ; the hues are the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we ruled out
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;media3's &lt;code&gt;setVideoEffects&lt;/code&gt;.&lt;/strong&gt; Its effects pipeline converts every frame to RGB before any effect runs, through the driver's YCbCr-to-RGB step into RGBA8, or for HDR a clamped BT.2020 path at medium precision. The codes the RPU needs are gone by then.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reading frames on the CPU&lt;/strong&gt; with an &lt;code&gt;ImageReader&lt;/code&gt; in P010 and uploading the planes as integer textures, for GPUs without the extension. It costs a 25 MB copy per 4K frame, and those GPUs are on the weakest devices, so they keep the second player.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where it stops
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The output is SDR on every screen, an HDR TV included.&lt;/li&gt;
&lt;li&gt;Dolby's level 2 and level 8 trims are not applied, so contrast and saturation can differ slightly from a licensed Dolby Vision display's own SDR picture.&lt;/li&gt;
&lt;li&gt;The Android emulator has neither a Main 10 HEVC decoder nor &lt;code&gt;GL_EXT_YUV_target&lt;/code&gt;, so this path needs a real device to see.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/video-format-support/" rel="noopener noreferrer"&gt;Video format support&lt;/a&gt;, what plays where.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/video-formats/" rel="noopener noreferrer"&gt;Video formats&lt;/a&gt;, how the app picks a player for a file, profile 5 included.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/changelog/#v5.5.1" rel="noopener noreferrer"&gt;The changelog for 5.5.1&lt;/a&gt;, the release this shipped in.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/yonto/two-video-players-in-one-app-and-the-rule-that-picks-one-4ff7"&gt;Two video players in one app, and the rule that picks one&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/yonto/one-kotlin-core-for-every-screen-what-is-shared-and-what-is-not-4abl"&gt;One Kotlin core for every screen&lt;/a&gt;, the series article on what is shared across platforms.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>androidkotlivideoopengln</category>
    </item>
    <item>
      <title>Versioning a fast-moving app: the rules that keep updates safe</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Wed, 18 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/versioning-a-fast-moving-app-the-rules-that-keep-updates-safe-2jf3</link>
      <guid>https://dev.to/yonto/versioning-a-fast-moving-app-the-rules-that-keep-updates-safe-2jf3</guid>
      <description>&lt;p&gt;Yonto Player ships often, and an Android install updates only when the new APK meets the platform's rules. So the way I version and cut a release is a short list of rules, each one with a reason behind it.&lt;/p&gt;

&lt;p&gt;This is the list. It is not clever, and that is the point of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  One version pair, in one file
&lt;/h2&gt;

&lt;p&gt;Every app module reads its version from a single pair in &lt;code&gt;gradle.properties&lt;/code&gt;. This is a simplified sketch of it, with made-up numbers and generic names:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="c"&gt;# gradle.properties (simplified sketch, made-up numbers)
# The release's version, read by every app module.
&lt;/span&gt;&lt;span class="py"&gt;app.versionCode&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;12&lt;/span&gt;
&lt;span class="py"&gt;app.versionName&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1.4.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;versionName&lt;/code&gt; is what people read: semantic, &lt;code&gt;MAJOR.MINOR.PATCH&lt;/code&gt;, and the git tag is &lt;code&gt;v&lt;/code&gt; plus it. &lt;code&gt;versionCode&lt;/code&gt; is what Android reads. The TV app and the phone app both take the same pair, so a release bumps both at once and the two stay in step.&lt;/p&gt;

&lt;h2&gt;
  
  
  PATCH goes up by one on every release
&lt;/h2&gt;

&lt;p&gt;The usual bump is PATCH, by exactly one. A release is usually a fix or a polish, and it should look small in the version too.&lt;/p&gt;

&lt;p&gt;MINOR and MAJOR move only when I decide a release marks a step, and each one resets the parts below it to zero. A change that merely feels big does not move them.&lt;/p&gt;

&lt;p&gt;The plugin contract has a version of its own, and it does not shape the app's version. They answer different questions, so each keeps its own number.&lt;/p&gt;

&lt;h2&gt;
  
  
  A version code that only goes up
&lt;/h2&gt;

&lt;p&gt;Android requires the &lt;code&gt;versionCode&lt;/code&gt; of an update to be higher than the installed one. So the code goes up by one on every release, whatever part of the name moved.&lt;/p&gt;

&lt;p&gt;It is a counter and not a value computed from the name. The next release is always the last one plus one, and the name can follow whatever semantic rules it likes.&lt;/p&gt;

&lt;h2&gt;
  
  
  A patch that must not carry main
&lt;/h2&gt;

&lt;p&gt;Sometimes the fix has to go out without the rest of &lt;code&gt;main&lt;/code&gt;. For that, the patch is cut from the last tag, not from &lt;code&gt;main&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# tag-to-branch flow for a patch (simplified sketch, made-up versions)&lt;/span&gt;
git switch &lt;span class="nt"&gt;-c&lt;/span&gt; release-1.4.3 v1.4.2        &lt;span class="c"&gt;# branch off the last tag&lt;/span&gt;
git cherry-pick &amp;lt;fix-commit&amp;gt;              &lt;span class="c"&gt;# the fix, once it has merged on main&lt;/span&gt;
&lt;span class="c"&gt;# bump the version pair, add the changelog entry, build and release from here&lt;/span&gt;
git tag &lt;span class="nt"&gt;-a&lt;/span&gt; v1.4.3 &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Release 1.4.3"&lt;/span&gt;
&lt;span class="c"&gt;# then a PR to main records the version pair and the changelog entry&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix lands on &lt;code&gt;main&lt;/code&gt; first and is cherry-picked second, so &lt;code&gt;main&lt;/code&gt; keeps it too. The last step writes the version back to &lt;code&gt;main&lt;/code&gt;, so the next build cut from there gets a &lt;code&gt;versionCode&lt;/code&gt; higher than the patch's. The branch builds with the module layout and asset names the tag had, so what it produces is the old shape plus the fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-releases and betas
&lt;/h2&gt;

&lt;p&gt;A beta is tagged with a suffix on the next target version, &lt;code&gt;v1.5.0-beta.1&lt;/code&gt;, and published as a GitHub pre-release. Its &lt;code&gt;versionCode&lt;/code&gt; goes up by one, like any other release.&lt;/p&gt;

&lt;p&gt;The app has a &lt;strong&gt;Beta updates&lt;/strong&gt; option in Settings → About on Android (released in 5.4.9) that lets an install receive pre-release builds. The plain "latest release" lookup skips pre-releases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two APKs per release
&lt;/h2&gt;

&lt;p&gt;A release carries two APKs, one for the TV app and one for the phone app, named &lt;code&gt;Yonto-AndroidTV-vX.Y.Z.apk&lt;/code&gt; and &lt;code&gt;Yonto-Phone-vX.Y.Z.apk&lt;/code&gt;, as the public releases page shows. Because one release serves both apps, a TV hotfix is a single tag with both APKs, the phone's rebuilt unchanged. After publishing I read the release's asset names back from GitHub to confirm they are the two I expect.&lt;/p&gt;

&lt;h2&gt;
  
  
  A changelog in the viewer's terms
&lt;/h2&gt;

&lt;p&gt;A changelog is written by hand, in the terms of the person holding the remote and not in the code's, and a release is not cut until its entry exists. &lt;code&gt;git log&lt;/code&gt; is the raw material for it, not the entry: a commit message says what changed in the code, and a viewer wants to know what is different when they sit down to watch.&lt;/p&gt;

&lt;p&gt;The entries are grouped by platform, under a heading of one fixed shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## 1.4.3 (version and date format as a sketch)&lt;/span&gt;

&lt;span class="gu"&gt;### All apps&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; (what changed, in the viewer's words)

&lt;span class="gu"&gt;### TV&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; (...)

&lt;span class="gu"&gt;### Phone and tablet&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; (...)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The site's build checks the release heading, &lt;code&gt;## X.Y.Z — date&lt;/code&gt;, and refuses to build on any other shape.&lt;/p&gt;

&lt;h2&gt;
  
  
  The order I cut a release in
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Bump the version pair and write the changelog entries on a branch that merges into &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Build both APKs from &lt;code&gt;main&lt;/code&gt; at that merge commit, so the file is what the tag names.&lt;/li&gt;
&lt;li&gt;Run the full verification line on that commit.&lt;/li&gt;
&lt;li&gt;Check each APK's reported &lt;code&gt;versionCode&lt;/code&gt;, &lt;code&gt;versionName&lt;/code&gt; and package with &lt;code&gt;aapt dump badging&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Install the previous release, install the new APK over it, and look that what the old install held is still there. The update path is the thing that has to work, so that is the path I test.&lt;/li&gt;
&lt;li&gt;Tag, push the tag, publish.&lt;/li&gt;
&lt;li&gt;Ask GitHub for the latest release and read the asset names back.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Releases are cut by hand, on purpose. Each step can be followed from the page, and the last one confirms the result from the outside, the way an install will see it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to take from it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make the code a counter, separate from the name.&lt;/li&gt;
&lt;li&gt;Make the usual bump the boring one, and the larger ones a decision.&lt;/li&gt;
&lt;li&gt;When a patch must not carry the rest of &lt;code&gt;main&lt;/code&gt;, branch from the tag, cherry-pick, and write the version back.&lt;/li&gt;
&lt;li&gt;Write the changelog in the reader's words, and let the build check what it can.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://player.yonto.app/changelog/" rel="noopener noreferrer"&gt;changelog&lt;/a&gt; shows the shape in practice, &lt;a href="https://player.yonto.app/docs/install-on-android-tv/" rel="noopener noreferrer"&gt;the install guide for Android TV&lt;/a&gt; shows what the TV's APK is for, and &lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;the developer docs&lt;/a&gt; describe the plugin contract and its own version. The SDK and CLI are in &lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;the plugins repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>android</category>
      <category>devops</category>
      <category>opensource</category>
      <category>git</category>
    </item>
    <item>
      <title>Choosing a JavaScript engine binding for Kotlin: the requirements and the spike</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Tue, 17 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/choosing-a-javascript-engine-binding-for-kotlin-the-requirements-and-the-spike-33ll</link>
      <guid>https://dev.to/yonto/choosing-a-javascript-engine-binding-for-kotlin-the-requirements-and-the-spike-33ll</guid>
      <description>&lt;p&gt;Picking a JavaScript engine binding for a Kotlin app looks like a library choice. For Yonto Player it was more, because everything a plugin does goes through it. So before I looked at a candidate I wrote down what the binding had to do, then checked each one in a throwaway spike. This post is about the list, the spike, what the chosen binding gave us, and what it costs.&lt;/p&gt;

&lt;p&gt;Here I only cover one question: given that plugins run on QuickJS, which binding to use, and how the runtime is hosted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two requirements, written down first
&lt;/h2&gt;

&lt;p&gt;Yonto Player is an Android TV, phone and tablet app that plays your own library, and its sources are small JavaScript plugins that talk to a server's API. Two facts turned into hard requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. It must run in plain JVM unit tests.&lt;/strong&gt; The repo's adapters are tested on the JVM, with a mock web server standing in for the real one. A binding that only loads on a device would make the plugin runtime the one part we could not test the same way as everything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Host calls must suspend, not block.&lt;/strong&gt; A plugin asks the host to fetch things, and a good plugin asks for several at once, with &lt;code&gt;Promise.all&lt;/code&gt; over a few &lt;code&gt;await&lt;/code&gt;ed host calls. If a host call blocks the engine's thread until it returns, three calls run one after another and "concurrent" is only a word. The host is Kotlin and coroutines, so the natural shape is a host function that is itself &lt;code&gt;suspend&lt;/code&gt;, and an engine that can park a promise until it finishes.&lt;/p&gt;

&lt;p&gt;Everything else was negotiable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The spike
&lt;/h2&gt;

&lt;p&gt;I checked three candidates against the two requirements, in September 2026, and wrote a small throwaway test for the one that looked right. quickjs-kt (1.0.15 at the time) met both. The other two I looked at did not meet both requirements for this use at that time, and they were built for other jobs, so I will leave them out of the rest of this post.&lt;/p&gt;

&lt;p&gt;For the binding that passed, the first test evaluated &lt;code&gt;1 + 1&lt;/code&gt; in a JVM unit test and asserted &lt;code&gt;2&lt;/code&gt;. That was the first proof that the library loads and evaluates on the JVM: its JVM artifact ships natives for macOS, Linux and Windows, so developer machines and CI need no extra setup.&lt;/p&gt;

&lt;p&gt;The second test mattered more. It registered a host function that sleeps, awaited it from JavaScript, then ran three under one &lt;code&gt;Promise.all&lt;/code&gt;. Each slept 300 ms: overlapping calls total about 300 ms, serial ones about 900 ms.&lt;/p&gt;

&lt;p&gt;In a JVM unit test the three took about 304 ms. It shows the one thing I needed to know, which is that the calls genuinely overlap.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a suspending host function looks like
&lt;/h2&gt;

&lt;p&gt;What made requirement 2 work is a registration call for functions whose body can suspend. Here is a simplified sketch of how the host side is shaped, not the app's exact code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch with generic names, not the app's exact code.&lt;/span&gt;
&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;HostScope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt;
    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;asyncFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;registerHost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HostScope&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;asyncFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"host_sleep"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class="nf"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLong&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;   &lt;span class="c1"&gt;// suspends, the engine's thread is free&lt;/span&gt;
        &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Platform side: hand each registration to the engine's own binding calls.&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EngineScope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;QuickJs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;HostScope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
        &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;asyncFunction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;suspend&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
        &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;asyncFunction&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Any&lt;/span&gt;&lt;span class="p"&gt;?&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;body&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toList&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The host functions are flat, with names like &lt;code&gt;host_sleep&lt;/code&gt;, and a bootstrap script written in JavaScript shapes them into the object a plugin sees. That keeps the Kotlin surface small and lets the CLI run the same shaping text.&lt;/p&gt;

&lt;h2&gt;
  
  
  One runtime, hosted per platform
&lt;/h2&gt;

&lt;p&gt;The app talks to a plugin runtime through a small interface: list what the plugin exported, and call a method with arguments as JSON to get JSON back. The shared code declares the factory (&lt;code&gt;createRuntime&lt;/code&gt; in this post) as an &lt;code&gt;expect&lt;/code&gt; function, and the platform provides the &lt;code&gt;actual&lt;/code&gt; one. In the repo the implementation lives in a shared source set rather than in each app, so there is one runtime and one set of tests for it.&lt;/p&gt;

&lt;p&gt;Each runtime runs its JavaScript on a dispatcher that it hands to the engine when it creates it. That is what let the host own the limits. A plugin call gets a memory ceiling (64 MB by default) and a time budget for the JavaScript it runs (20 seconds, which the &lt;a href="https://player.yonto.app/docs/developers/plugin-reference/" rel="noopener noreferrer"&gt;plugin reference&lt;/a&gt; also documents). Time spent waiting on a host call does not count against that budget, because the call suspends, and a call that never finishes is still ended at 85 seconds, as the reference says. A runaway &lt;code&gt;while (true)&lt;/code&gt; is ended by the engine's interrupt, which only an engine-level hook can do.&lt;/p&gt;

&lt;p&gt;A contract test lives in the shared code and runs on every target against whatever &lt;code&gt;createRuntime&lt;/code&gt; gives it, so the JVM is one of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  One engine in the CLI too
&lt;/h2&gt;

&lt;p&gt;The second thing the choice bought is less obvious. Authors write plugins on their own computers with a Node command line tool. If it ran the plugin in Node's own engine, a plugin could pass on a laptop and misbehave on a television, because two engines can agree on every global name and still differ in what regular expressions and string functions do.&lt;/p&gt;

&lt;p&gt;So the CLI runs the plugin on QuickJS as well, compiled to WebAssembly. It uses the same host bootstrap text as the device, the same memory and time limits, and an interrupt handler for the time budget rather than a &lt;code&gt;Promise.race&lt;/code&gt;, which cannot stop a loop that never yields. "It passes on my machine" and "it works on a television" end up close to the same statement, not the same one, because there is one known difference in the list of globals (below).&lt;/p&gt;

&lt;p&gt;Requirement 2 applies here too. The WebAssembly library has an easy way to make a host call that pauses the whole runtime until it finishes. That fails requirement 2, because the host calls then run in sequence. In a short spike, three 50 ms host calls under one &lt;code&gt;Promise.all&lt;/code&gt; took over 120 ms that way. The variant that returns a pending promise and settles it later took about 52 ms for the same three, and that is the one the CLI uses.&lt;/p&gt;

&lt;p&gt;I did not want to take it on trust that two builds of QuickJS agree. A recorded list of the global names the device's engine offers lives in the CLI's conformance folder, and a test (both are in the public plugins repository) compares it with the CLI's list in both directions. The one known difference is &lt;code&gt;Atomics&lt;/code&gt;, which the Kotlin binding's build enables and the published WebAssembly build does not. The test names it, so a second difference fails the test.&lt;/p&gt;

&lt;h2&gt;
  
  
  The costs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Native code.&lt;/strong&gt; The engine is a native library per ABI. In the spike the arm64 one was 903 KB and the armeabi-v7a one was 642 KB, and the app ships those two ABIs only. They are stored uncompressed, so unlike dex code they do not shrink.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A recent toolchain.&lt;/strong&gt; The binding needs a recent Kotlin and a high compile SDK, so the repo has to stay current to take its releases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Handle discipline in the CLI.&lt;/strong&gt; In the WebAssembly engine every handle has to be disposed, and a leak aborts the process at teardown rather than raising a JavaScript error. It wants a scoped helper from the first line.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Two packages to keep in step.&lt;/strong&gt; The CLI's fidelity depends on a WebAssembly build tracking the Kotlin binding's engine build. The globals test turns a mismatch into a failing test.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They are the price of testing the plugin runtime like everything else in the repo, and of giving plugin authors the engine their plugin will meet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;Write the requirements first and make them testable. For me that was a &lt;code&gt;1 + 1&lt;/code&gt; test and a three-calls-under-&lt;code&gt;Promise.all&lt;/code&gt; test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/plugin-reference/" rel="noopener noreferrer"&gt;The plugin reference, including the limits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/test-and-debug/" rel="noopener noreferrer"&gt;Test and debug a plugin on your computer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;Developer docs overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;The plugins repository, including the CLI and its conformance files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
    <item>
      <title>From file names to a poster wall: parsing, matching and keeping paths private</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Mon, 16 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/from-file-names-to-a-poster-wall-parsing-matching-and-keeping-paths-private-4e1d</link>
      <guid>https://dev.to/yonto/from-file-names-to-a-poster-wall-parsing-matching-and-keeping-paths-private-4e1d</guid>
      <description>&lt;p&gt;Point a media player at a folder of video files and you get a list of file names. &lt;code&gt;Holiday in Lisbon 2019.mp4&lt;/code&gt;, &lt;code&gt;My Show S02E05.mkv&lt;/code&gt;, &lt;code&gt;Garden Documentary (2014).mkv&lt;/code&gt;, &lt;code&gt;IMG_2041.mov&lt;/code&gt;. What a person wants is a wall of posters, with Films, Series and their seasons, and a description when they open one.&lt;/p&gt;

&lt;p&gt;Yonto Player does that for the video files you keep on a NAS, a USB drive or the device itself. This post covers the parser, the grouping, the order of artwork, and a lookup built so that no path or file name leaves the device.&lt;/p&gt;

&lt;h2&gt;
  
  
  The parser: decline to guess when the name is unclear
&lt;/h2&gt;

&lt;p&gt;The parser is written from scratch in Kotlin. The idea is simple: split the name into tokens and find the first one that cannot be part of a title. That is where the title ends.&lt;/p&gt;

&lt;p&gt;A marker that ends a title is a season or episode (&lt;code&gt;S02E05&lt;/code&gt;, &lt;code&gt;2nd Season&lt;/code&gt;, &lt;code&gt;第3集&lt;/code&gt;), a date, a year, or a descriptive tag such as an edition. Here is the shape of it, as a simplified sketch with generic names, not the real file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the idea, not the real parser.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;):&lt;/span&gt; &lt;span class="nc"&gt;Parsed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;titleEnd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;season&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;episode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;

    &lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;cut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;titleEnd&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;titleEnd&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;withIndex&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;se&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;seasonAndEpisode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;se&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;cut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;season&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;se&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;season&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;episode&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;se&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;episode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nf"&gt;isYear&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;cut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toInt&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nf"&gt;isReleaseTag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;cut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;title&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;titleEnd&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;joinToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Parsed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;season&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;episode&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real code has far more cases; the telling ones are where it declines to read a marker.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A year is 1900 to 2030, and never the first word.&lt;/strong&gt; &lt;code&gt;1917&lt;/code&gt; and &lt;code&gt;2012&lt;/code&gt; are titles. &lt;code&gt;Mars 2049&lt;/code&gt; is a title with no year, and &lt;code&gt;Mars 2049 (2017)&lt;/code&gt; finds 2017. Of a run of years, the last one is the year.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A bare number is an episode only where the structure says it is a series.&lt;/strong&gt; &lt;code&gt;Garden Notes - 3.mkv&lt;/code&gt; is a film. In a name with a hyphen and a number, the number alone is not enough; a file inside a season folder is.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Words that are also words stay words.&lt;/strong&gt; &lt;code&gt;Space Saga Episode 4&lt;/code&gt; keeps its number in the title.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three come from one decision: where a name gives no clear signal, a wrong guess is worse than none. A film called an episode moves into Series. So a name that says nothing, such as a camera counter or a timestamp, has no title, and the video stays under &lt;strong&gt;Other videos&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Names are normalised first (NFKC). English season and episode markers are read, and so are the Chinese (&lt;code&gt;第二季&lt;/code&gt;, &lt;code&gt;第3集&lt;/code&gt;) and Spanish (&lt;code&gt;Temporada 1&lt;/code&gt;, &lt;code&gt;Capítulo 2&lt;/code&gt;) ones, which are rewritten to the same tokens first.&lt;/p&gt;

&lt;h2&gt;
  
  
  From parsed names to Films and Series
&lt;/h2&gt;

&lt;p&gt;The grouping step reads each file together with the folders above it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The nearest folder with a season in its name (&lt;code&gt;Season 01&lt;/code&gt;, &lt;code&gt;第一季&lt;/code&gt;, &lt;code&gt;Temporada 2&lt;/code&gt;) numbers a file that has no number of its own.&lt;/li&gt;
&lt;li&gt;The nearest folder with a real title (not a container such as &lt;code&gt;Movies&lt;/code&gt;) names a file that has none.&lt;/li&gt;
&lt;li&gt;A file's own title wins over a folder's, so a flat folder of many shows stays many shows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A series needs an episode number or a date, and a title from the file or from a show folder. Anything short of that stays under Other videos.&lt;/p&gt;

&lt;p&gt;A rescan is incremental: it lists every folder that has subfolders, and skips a leaf folder whose modified time has not changed. Skipping only leaves is deliberate: a directory's time changes when something is added directly in it, not two levels down, and the leaves are most of a NAS. A scan runs when you open the source and every half hour, and &lt;strong&gt;Rescan everything&lt;/strong&gt; reads all folders again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Artwork has an order
&lt;/h2&gt;

&lt;p&gt;Each title gets its poster and description from three places, in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Your own files.&lt;/strong&gt; Posters and backdrops named the way Kodi, Jellyfin and Emby name them (&lt;code&gt;poster.jpg&lt;/code&gt;, &lt;code&gt;folder.jpg&lt;/code&gt;, &lt;code&gt;&amp;lt;video name&amp;gt;-poster.jpg&lt;/code&gt;, &lt;code&gt;fanart.jpg&lt;/code&gt;) and the &lt;code&gt;.nfo&lt;/code&gt; files those tools write. A picture named for a folder counts only where the folder holds one title's videos, because a &lt;code&gt;poster.jpg&lt;/code&gt; in a folder of thirty films belongs to none of them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An online lookup, for what is still missing.&lt;/strong&gt; It fills gaps and never replaces what your files say.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A frame from the video.&lt;/strong&gt; A title with neither shows a picture of its video, a thumbnail or a frame from a little way in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The merge is small and explicit: each field takes your file's value first and the match's only when yours is empty. A title with both a poster and a description of its own is not looked up at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  What leaves the device
&lt;/h2&gt;

&lt;p&gt;The lookup is asked with the title and year as read from the file and folder names (a file with no title of its own takes the nearest folder's), the kind (film or series), the app's language, any ids found in a &lt;code&gt;.nfo&lt;/code&gt; or in the name, and, for two series of the same name, an episode number to tell them apart. It is not asked with a path or the server's address.&lt;/p&gt;

&lt;p&gt;The query type has no field for a path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the idea, not the real file.&lt;/span&gt;
&lt;span class="kd"&gt;data class&lt;/span&gt; &lt;span class="nc"&gt;TitleQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// parsed from the name&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TitleKind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;// FILM or SERIES&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;ExternalIds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;ExternalIds&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;episode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;EpisodeProbe&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your own artwork and &lt;code&gt;.nfo&lt;/code&gt; files are not sent. Each files source has a switch, &lt;strong&gt;Look up posters and descriptions online&lt;/strong&gt;, and with it off nothing is sent for that source. If the service cannot be reached, the library shows what it has and retries later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoring the answers on the device
&lt;/h2&gt;

&lt;p&gt;The service hands back every title that fits a search, with every name each has. It does not choose. The app chooses, in the matcher.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If the &lt;code&gt;.nfo&lt;/code&gt; or the file name carries an id (&lt;code&gt;{tmdb-603}&lt;/code&gt;, &lt;code&gt;[imdbid-tt0133093]&lt;/code&gt;), the title is found by that id.&lt;/li&gt;
&lt;li&gt;Otherwise the app searches by name, and each result is scored.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The scoring idea, simplified:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch of the idea, not the real matcher.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wanted&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Kind&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kind&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="py"&gt;score&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;when&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;wanted&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;listOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;originalTitle&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;aliases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;any&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;fold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="n"&gt;wanted&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;           &lt;span class="c1"&gt;// not this title at all&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;val&lt;/span&gt; &lt;span class="py"&gt;off&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="n"&gt;year&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;off&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;      &lt;span class="c1"&gt;// a year is allowed to be one off&lt;/span&gt;
        &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;off&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Names are compared after a fold that drops case, accents, punctuation, spaces and a leading "the", and turns Traditional characters into Simplified.&lt;/p&gt;

&lt;p&gt;The app takes a result only when it is alone at the top. Two results with the same score are not a match, because a poster for the wrong show is worse than none. For series that tie, the app asks whether each has the files' episode, and then whether its title matches, for up to a few candidates. If that does not settle it, the title stays unmatched.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the match is wrong
&lt;/h2&gt;

&lt;p&gt;A match can be wrong, so the viewer has the last word. On a title's page, &lt;strong&gt;Wrong title?&lt;/strong&gt; opens a search the viewer can edit, lists what it finds with posters and years, and offers &lt;strong&gt;None of these: use the file names&lt;/strong&gt;. The choice is kept, and no later rescan or lookup changes it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Let a parser decline to guess where the name gives no clear signal.&lt;/li&gt;
&lt;li&gt;Make the privacy rule visible in the types: the query type has no field for a path.&lt;/li&gt;
&lt;li&gt;Score candidates on the device, with a "must be alone at the top" rule, and give the viewer an override.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/docs/files-nas-usb-android-tv/" rel="noopener noreferrer"&gt;Play video files from a NAS or USB drive on Android TV&lt;/a&gt;: the library, local artwork and the online lookup from the viewer's side&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/sources/" rel="noopener noreferrer"&gt;Sources and which video files play&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://player.yonto.app/privacy/" rel="noopener noreferrer"&gt;Privacy policy&lt;/a&gt;: what the apps send&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/developers/" rel="noopener noreferrer"&gt;Developer docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yonto-app/yonto-player-plugins" rel="noopener noreferrer"&gt;yonto-player-plugins on GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>kotlin</category>
      <category>android</category>
      <category>privacy</category>
      <category>opensource</category>
    </item>
    <item>
      <title>One Cast button, three kinds of receiver: how a phone decides what to send</title>
      <dc:creator>Yonto Player</dc:creator>
      <pubDate>Sun, 15 Nov 2026 20:00:00 +0000</pubDate>
      <link>https://dev.to/yonto/one-cast-button-three-kinds-of-receiver-how-a-phone-decides-what-to-send-5nj</link>
      <guid>https://dev.to/yonto/one-cast-button-three-kinds-of-receiver-how-a-phone-decides-what-to-send-5nj</guid>
      <description>&lt;p&gt;The Cast button in Yonto Player's phone app looks like one feature. Behind it are three receivers that have almost nothing in common: a Chromecast, an AirPlay screen and a DLNA TV. They speak different protocols, find the phone in different ways, and play different files.&lt;/p&gt;

&lt;p&gt;This post is about the part I find most interesting, which is not the protocols. It is the question every cast has to answer before it sends a single byte: what exactly should the receiver be given?&lt;/p&gt;

&lt;h2&gt;
  
  
  The receiver fetches the video itself
&lt;/h2&gt;

&lt;p&gt;All three work the same way at the top. The phone does not push video frames to the TV. It tells the receiver an address, the receiver fetches the video from that address, and the phone becomes a remote with a play button, a slider and a stop button.&lt;/p&gt;

&lt;p&gt;So the phone has to answer two things first. Can the receiver reach the video where it already is? And can the receiver actually play what it finds there?&lt;/p&gt;

&lt;p&gt;For the first one, the app serves the video itself when the receiver cannot just fetch it. If the source needs request headers or a sign-in, or the video lives on the phone, the app relays it from a small server on the phone's Wi-Fi address. Otherwise the receiver goes straight to the source. For a Jellyfin, Emby or Plex server, the app also asks the server again for a version the receiver plays, because the receiver's decoders are not the phone's.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three protocols, one session interface
&lt;/h2&gt;

&lt;p&gt;Each receiver kind is a session class behind one interface, &lt;code&gt;CastSessionClient&lt;/code&gt;, with the same small vocabulary: load, play, pause, seek, stop, and a stream of position updates. Google Cast uses Google's sender SDK. Apple publishes no sender SDK for Android, so AirPlay goes through an open-source library that speaks AirPlay 2 video. DLNA is our own code: an SSDP search, the device description, and a dozen SOAP calls such as &lt;code&gt;SetAVTransportURI&lt;/code&gt;, &lt;code&gt;Play&lt;/code&gt; and &lt;code&gt;Seek&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The player on the phone hands playback over to the session, takes it back when you press Stop casting, and resumes at the same place.&lt;/p&gt;

&lt;p&gt;The receivers differ in what they report back. DLNA has no events without running a server on the phone, so that session polls the receiver once a second. A DLNA renderer that stops before it ever starts has met a format it cannot play, and the phone says so instead of showing a black screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide by what the file is
&lt;/h2&gt;

&lt;p&gt;The interesting decision is what to send. Receivers differ in which containers they open and which codecs they decode, and a title's address says little about any of that. A media server's stream address often has no file extension at all, and a file called &lt;code&gt;.mp4&lt;/code&gt; can be an MKV.&lt;/p&gt;

&lt;p&gt;So the cast does not trust the name. Before it loads anything on the receiver, the app reads the first 256 bytes of the stream and recognises the container from its signature. The name is only the fallback when the bytes cannot be read. It is a short list of checks, such as Matroska's header and its document type for MKV and WebM, the &lt;code&gt;ftyp&lt;/code&gt; box for MP4 and QuickTime, and the repeating sync byte of an MPEG transport stream.&lt;/p&gt;

&lt;p&gt;Each receiver is described by a small capability record: the containers it opens as they are, and the codecs it decodes. The decision is made in two steps, and here is a simplified sketch of them (generic names, not the real code):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight kotlin"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified sketch, not the real classes. Step 1 looks at the container only.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;needsRepackaging&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;?,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Receiver&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nc"&gt;Boolean&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;containers&lt;/span&gt;

&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LoadSpec&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Receiver&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remuxer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Remuxer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(!&lt;/span&gt;&lt;span class="nf"&gt;needsRepackaging&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// send as is&lt;/span&gt;
    &lt;span class="n"&gt;remuxer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="p"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Step 2, inside the remuxer, after it has probed the stream.&lt;/span&gt;
&lt;span class="k"&gt;fun&lt;/span&gt; &lt;span class="nf"&gt;remux&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Probe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Receiver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;video&lt;/span&gt; &lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;video&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;encodePictureAsH264&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;// convert&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="nf"&gt;copyPicture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reencodeAudio&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;probe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;audio&lt;/span&gt; &lt;span class="p"&gt;!&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;receiver&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;audio&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;// repackage&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first step is cheap and needs no knowledge of codecs: does this receiver open this container? If it does, the load goes straight through to the Chromecast, AirPlay or DLNA session untouched. If not, a remuxer takes over, and only once it has probed the file does it decide between copying the picture and encoding it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three outcomes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Send it as is.&lt;/strong&gt; For an MP4 this is usually all it takes: the receiver fetches the file and plays it. A Chromecast opens MP4, WebM and MPEG-TS with H.264. An AirPlay screen takes MP4 and HLS with H.264 or H.265. A DLNA renderer is assumed to take MP4 and MPEG-TS with H.264, and its own list of supported types can add more. A TV that lists MKV is sent the MKV as it is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Repackage the container.&lt;/strong&gt; Often only the box is the problem: an MKV with H.264 video, say, that a Chromecast will not open. The phone then reads the file with libVLC, copies the video and audio streams into HLS segments without touching the picture, and serves the playlist on the LAN. If the audio is something the receiver does not decode, such as DTS, only the audio is converted, to AAC. Copying the picture involves no decoding or encoding of it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Convert the picture.&lt;/strong&gt; Sometimes the picture itself is the problem: an AVI with MJPEG or Xvid video, or H.265 on a Chromecast. libVLC decodes the picture and the phone's own hardware encoder, through MediaCodec, makes H.264 from it, with AAC sound. A picture larger than the receiver takes is scaled down, and HDR10 or HLG is tone-mapped to SDR. If the phone's encoder cannot take the picture's size, the cast says it cannot play it, rather than trying anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  The delay
&lt;/h2&gt;

&lt;p&gt;Sending as is needs no converting (the first-bytes read still takes a moment). The other two start a few seconds later, because the phone has to probe the file and write the first segments before the receiver has anything to play. The code waits for three segments before it hands the receiver the playlist, and gives up on a source that has not produced them in 30 seconds.&lt;/p&gt;

&lt;p&gt;Converting also keeps the phone's decoder and encoder busy while the film plays, which copying does not, so the app tries the lightest option that works first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeking in a stream that is still being written
&lt;/h2&gt;

&lt;p&gt;A repackaged stream starts where the cast starts, so its clock is behind the title's. The wrapper keeps an offset and translates, so the slider and the position you see are the title's.&lt;/p&gt;

&lt;p&gt;A seek inside what is already written goes to the receiver. A seek past it cannot, because the receiver cannot seek into video that does not exist yet. So the phone starts a new remux from there and loads the new playlist, keeping the old stream until the receiver answers, so the receiver never asks for a file that was deleted under it. The same happens when someone scrubs on the receiver's own remote past the written edge.&lt;/p&gt;

&lt;h2&gt;
  
  
  What each receiver can be told
&lt;/h2&gt;

&lt;p&gt;Chromecast, AirPlay and DLNA all take play, pause, seek and stop, and report a position back. Beyond that they differ, and the phone only sends what a receiver can use.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Subtitle files and audio-track choice depend on the receiver: AirPlay takes tracks only inside an HLS stream, and DLNA renderers handle subtitle files each in their own way, so the phone sends none to either.&lt;/li&gt;
&lt;li&gt;A repackaged video is HLS, so it plays where the TV accepts HLS.&lt;/li&gt;
&lt;li&gt;An AirPlay screen has to allow anyone on the network, so a Mac shows up in the list once it is set to "Anyone on the same network".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are properties of the receiver, so the design is to detect them and say so, not to leave a black screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to take away
&lt;/h2&gt;

&lt;p&gt;The thing I would reuse is the shape. Describe a receiver as data, not as a class. Look at the file's bytes, not its name. Pick the cheapest transformation that makes the two agree, and say what the receiver cannot do. The protocol code stays small because the decision lives in one place and the three session classes only carry out the result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read more
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/cast-chromecast-airplay/" rel="noopener noreferrer"&gt;Cast to a Chromecast, an AirPlay screen or a DLNA TV&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/video-formats/" rel="noopener noreferrer"&gt;Video formats Yonto Player plays&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://player.yonto.app/docs/troubleshooting/" rel="noopener noreferrer"&gt;Troubleshooting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>android</category>
      <category>kotlin</category>
      <category>networking</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
