<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Blogs by Team Spotube]]></title><description><![CDATA[Blogs by Team Spotube]]></description><link>https://spotube.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 23:59:46 GMT</lastBuildDate><atom:link href="https://spotube.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The golden age of media player skins: Winamp, Sonique and the custom player]]></title><description><![CDATA[How Winamp, Sonique and Windows Media Player let anyone repaint their music player, what was inside a .wsz or .wmz file, why skins faded, and who is…]]></description><link>https://spotube.hashnode.dev/the-golden-age-of-media-player-skins-winamp-sonique-and-the-custom-player</link><guid isPermaLink="true">https://spotube.hashnode.dev/the-golden-age-of-media-player-skins-winamp-sonique-and-the-custom-player</guid><category><![CDATA[Design]]></category><category><![CDATA[history]]></category><category><![CDATA[skins]]></category><category><![CDATA[desktop]]></category><category><![CDATA[explainer]]></category><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Fri, 04 Dec 2026 03:18:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/aed42320-90a0-4e04-8b46-8a7b749231ed.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Around the year 2000, a music player was not an app you opened. It was an object that lived on your desktop. It could be a chrome slab with a green LCD, a cartoon frog, a blob of liquid glass or a fake car stereo, and the one you picked said something about you.</p>
<p>That whole culture ran on a surprisingly simple trick: a folder of images and a few text files, zipped up and renamed. This post is about that trick, the players that made it famous, why the scene went quiet, and the people who saved more than a hundred thousand skins from disappearing. We already wrote a broader <a href="https://spotube.org/blog/desktop-music-players-a-short-history">history of desktop music players</a>, so here we stay zoomed in on the skins themselves.</p>
<h2>The player as a canvas</h2>
<p><a href="https://en.wikipedia.org/wiki/Winamp">Winamp</a> started as a tiny freeware MP3 player. Version 0.20a came out on April 21, 1997, with a menu bar and almost nothing else. Winamp 2.0 arrived on September 8, 1998, and with it Nullsoft published documentation on how to make skins and invited users to share them on Winamp.com.</p>
<p>People took the invitation seriously. By the end of 1998 there were already hundreds of skins, and by 2000 there were nearly 3,000. Genres formed: "Stereo", "Anime" and, our favorite, "Ugly". Community sites such as 1001Skins.com and Skinz.org hosted thousands of designs. Wikipedia's article lists Klingon, iPod and Etch A Sketch skins among the odder ones.</p>
<p>The format was popular enough to escape Winamp entirely. <a href="https://en.wikipedia.org/wiki/XMMS">XMMS</a>, the classic Linux player, could load unmodified Winamp 2 skin files. A skin was not a Winamp feature anymore. It was a small file format that other players adopted.</p>
<h2>What is actually inside a .wsz</h2>
<p>Here is the part we love. A classic Winamp skin is a <code>.wsz</code> file, and a <code>.wsz</code> file is just a <a href="https://en.wikipedia.org/wiki/ZIP_(file_format)">ZIP archive</a> with a different extension. Jordan Eldredge, who rebuilt Winamp 2 in the browser as Webamp, explains it in <a href="https://jordaneldredge.com/how-winamp2-js-loads-native-skins-in-your-browser/">How Winamp2-js loads native skins in your browser</a>: rename it to <code>.zip</code>, open it, and you find plain, uncompressed <a href="https://en.wikipedia.org/wiki/BMP_file_format">BMP</a> images.</p>
<p>The file names are fixed. Winamp looks for <code>MAIN.BMP</code>, <code>CBUTTONS.BMP</code>, <code>TITLEBAR.BMP</code>, <code>NUMBERS.BMP</code>, <code>POSBAR.BMP</code>, <code>VOLUME.BMP</code>, <code>EQMAIN.BMP</code>, <code>PLEDIT.BMP</code> and friends, plus a few text files: <code>VISCOLOR.TXT</code> for the visualizer colors, <code>PLEDIT.TXT</code> for playlist colors, and <code>REGION.TXT</code> for the window outline. Webamp's parser shows how forgiving this was: if <code>VISCOLOR.TXT</code> or <code>PLEDIT.TXT</code> is missing or broken, it quietly uses the default skin's colors.</p>
<p>Each BMP is a <a href="https://en.wikipedia.org/wiki/Texture_atlas">sprite sheet</a>, the same trick old video games used. Many small images are packed into one bitmap, and the player cuts out rectangles at known coordinates. Webamp's <a href="https://github.com/captbaritone/webamp/blob/master/packages/webamp/js/skinSprites.ts"><code>skinSprites.ts</code></a> is the best map of those coordinates we know of. A few real entries:</p>
<pre><code class="language-text">MAIN.BMP      main window background    x=0   y=0   275 x 116
CBUTTONS.BMP  play button (normal)      x=23  y=0    23 x 18
CBUTTONS.BMP  play button (pressed)     x=23  y=18   23 x 18
CBUTTONS.BMP  stop button (normal)      x=69  y=0    23 x 18
NUMBERS.BMP   digit 0                   x=0   y=0     9 x 13
NUMBERS.BMP   digit 1                   x=9   y=0     9 x 13
</code></pre>
<p>Notice the pattern in <code>CBUTTONS.BMP</code>. The five transport buttons sit side by side, each 23 pixels wide, so the play button starts at x = 1 × 23 = 23 and stop at x = 3 × 23 = 69. The pressed version of every button sits directly below it, 18 pixels down. When you click play, Winamp does not draw anything new. It just copies a different 23 × 18 rectangle from the same bitmap onto the same spot of the window.</p>
<p>The time display works the same way. Each digit in <code>NUMBERS.BMP</code> is 9 pixels wide, so digit <em>n</em> lives at x = 9 × <em>n</em>. To show <code>3:07</code>, the player copies the rectangles at x = 27, 0 and 63. A skinner who wanted a Nixie tube clock or a hand-drawn chalkboard clock only had to paint ten digits in the right slots.</p>
<p><img src="https://spotube.org/images/blog/golden-age-of-media-player-skins/anim/wsz-unpacked.gif" alt="A file icon labelled neon-deck.wsz gets renamed to neon-deck.zip with a little pencil, then unzips with a flash. Bitmap sheets fly out and fan across a dark desk: MAIN.BMP 275 x 116, CBUTTONS.BMP, NUMBERS.BMP and TITLEBAR.BMP, followed by two small text cards, VISCOLOR.TXT and REGION.TXT. The camera zooms into CBUTTONS.BMP, which shows two rows of chunky chrome buttons. A dashed 23 x 18 box highlights the play button at x = 23, y = 0, and a second box highlights the pressed play button directly below at y = 18. A mouse cursor clicks play on an assembled neon player window, and the button on the window swaps to the pressed crop from the lower row." /></p>
<p><em>A classic skin is a renamed zip of sprite sheets. Pressing a button just swaps which rectangle gets copied.</em></p>
<p>This design has a big consequence. A classic skin can change how every pixel looks, but it cannot move anything. The play button is always where Winamp puts it, the window is always 275 × 116. Eldredge describes classic skins as "basically a glorified set of sprite sheets" that "could change the appearance of the player but not the layout." Inside those limits, people still made wildly different players, which says a lot about the skinners.</p>
<h2>Breaking out of the rectangle</h2>
<p>Windows are rectangles, and a lot of skin art was not. Winamp's answer was <code>REGION.TXT</code>. The <a href="https://github.com/captbaritone/webamp/blob/master/packages/webamp/assets/skins/base-2.91/REGION.TXT">default skin's <code>REGION.TXT</code></a> that ships with Webamp still carries the original help text, with a note from Justin Frankel crediting Adam Kennedy for the documentation. The idea: list polygons, and only the pixels inside them are drawn. The x coordinates go from 0 to 275 and y from 0 to 116.</p>
<p>The simplest example from that file trims a single pixel row off the top and notches the edges below the title bar:</p>
<pre><code class="language-ini">[Normal]
NumPoints=8
PointList=0,1, 275,1, 275,14, 274,14, 274,115, 1,115, 1,14, 0,14
</code></pre>
<p>Eight points, walked clockwise, and Winamp closes the shape for you. Add more polygons and you can punch holes, round corners or cut the window into floating islands. The same file notes that <code>[WindowShade]</code> and <code>[Equalizer]</code> sections shape the other windows.</p>
<p><a href="https://en.wikipedia.org/wiki/Windows_Media_Player">Windows Media Player</a> took a different route. Version 7.0 shipped on June 19, 2000, and brought both skins and visualizations. A WMP skin is a <a href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmp/skin-files">group of files</a>: an XML skin definition with a <code>.wms</code> extension, art files (BMP, GIF, JPEG or PNG) and optional JScript files. To ship it, Microsoft's SDK tells you to <a href="https://learn.microsoft.com/en-us/previous-versions/aa386408(v=vs.85)">zip everything and rename the archive to <code>.wmz</code></a>. Yes, the same zip trick again.</p>
<p>Inside the definition you start with one <code>THEME</code> element and at least one <code>VIEW</code>, as the <a href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmp/skin-definition-file-structure">skin definition file structure</a> page describes. Instead of polygons, a view sets a <code>backgroundImage</code> and a <code>clippingColor</code>: every pixel of that color is cut out of the window. Paint the background on bright magenta, declare magenta as the clipping color, and the magenta vanishes. Groups of buttons could even be defined with an image map, a second picture that marks which areas of the background trigger which action, so skinners did not have to type a coordinate for every button.</p>
<p><img src="https://spotube.org/images/blog/golden-age-of-media-player-skins/anim/shaped-windows.gif" alt="Split screen. On the left, a rectangular 275 x 116 bitmap of an invented chrome player with a jagged fin on top. A REGION.TXT entry with NumPoints=8 lists its points one by one, each appearing as a numbered glowing dot on the outline, a polygon closes through them, and everything outside the polygon fades away to reveal the desktop wallpaper behind. On the right, a rounded, organic player blob painted on a solid magenta background. A label reads clippingColor = #FF00FF, a scanline sweeps down the image, and every magenta pixel turns transparent, leaving the blob floating over the desktop with a soft neon glow." /></p>
<p><em>Two ways to escape the rectangle: Winamp lists polygons, WMP cuts out one color.</em></p>
<p>Then there was <a href="https://en.wikipedia.org/wiki/Sonique_(media_player)">Sonique</a>, the player that made everyone else look boxy. It debuted in January 1998, was built by Andrew McCann and Ian Lyman's company Mediascience in Bozeman, Montana, and was sold to Lycos in 1999 for US$38.8 million. Wikipedia describes it as second only to Winamp in popularity, with support for irregular skins, an animated menu, plug-in visualizations and a 20-band equalizer. We could not find a solid primary source for how Sonique's skin files were structured internally, so we will leave that part alone instead of guessing.</p>
<h2>Modern skins: when the skin got a brain</h2>
<p>Classic skins could not move a button. The next generation fixed that. Winamp3, a full rewrite released on August 9, 2002, introduced a new skin format, and Winamp 5 (December 2003) kept it alongside classic skins. In Wikipedia's words, Winamp 5 supports "classic" skins built from static bitmaps and freeform "modern" skins with true alpha transparency, scripting and a docked toolbar.</p>
<p>Eldredge's write up on <a href="https://jordaneldredge.com/webamp-modern/">rendering modern skins in the browser</a> explains the guts. Modern skins shipped as <code>.wal</code> files (yes, zip again) holding XML that describes the interface, images, and compiled scripts in a language called MAKI, short for "Make a killer interface". XML plus MAKI, he notes, worked a lot like HTML plus JavaScript. Skinners could build sliding drawers, custom animations and controls that did not exist in the stock player.</p>
<p>That power came with a cost. A modern skin was a small program, so making one meant learning a scripting language and a compiler, not just a paint program. Many skinners never left the classic format, and Winamp 5 kept supporting it for exactly that reason.</p>
<h2>Why the skins faded</h2>
<p>There was no single moment when skins died. It was more like several floors of a building quietly being rented to other tenants. Here is how we see it.</p>
<p><strong>The OS learned to dress up.</strong> Once the operating system itself shipped glossy themes, the gap between a boring OS and an exciting player got smaller. We covered that glossy era in <a href="https://spotube.org/blog/frutiger-aero-is-back">Frutiger Aero: why the glossy 2000s look is back</a>.</p>
<p><strong>The library won over the window.</strong> As collections grew, people spent more time in a big library window than in a tiny floating deck. Winamp itself moved that way: version 5.5 (2007) made a unified player and media library skin called "Bento" the default.</p>
<p><strong>The music moved online.</strong> A streaming app is a window into someone else's catalog. Its interface is part of the product and is often shared with a website and a phone app, so letting users replace every pixel stops being simple.</p>
<p><strong>The hosts disappeared.</strong> AOL announced in November 2013 that Winamp.com would shut down (the site survived after a sale to Radionomy in 2014). Eldredge noticed around 2018 that the old skin sites were "going the way of the dinosaurs."</p>
<p>And Microsoft has now closed the last big door. Its own SDK pages carry a warning that skins will no longer be supported in Windows Media Player Legacy starting November 10, 2026, on Windows 11 version 24H2 and later.</p>
<h2>The museum: saving 100,000 tiny artworks</h2>
<p>Skins are art made by thousands of hobbyists, often credited only by a nickname in a readme, and art like that disappears quietly. The rescue started with one person and a tweet.</p>
<p>Eldredge tells the story in <a href="https://jordaneldredge.com/ia-skins/">Preserving Winamp skins for posterity at the Internet Archive</a>. While testing <a href="https://webamp.org/">Webamp</a>, his HTML5 and JavaScript reimplementation of Winamp 2, he collected old skins and saw how many sites were going offline. In 2018 he asked whether the Internet Archive could help, was connected with archivist Jason Scott, and together they uploaded over 5,000 skins. On October 2, 2018 the Archive announced the collection in a post called <a href="https://blog.archive.org/2018/10/02/dont-click-on-the-llama/">Don't Click on the Llama</a>, along with Webamp as an optional player across its audio items.</p>
<p>That collection grew into the <a href="https://skins.webamp.org/">Winamp Skin Museum</a>, a fast, searchable site where you can scroll through previews and load any skin into a working Webamp. A bulk upload feature pushed the museum past 100,000 skins, and every upload is sent back to the Internet Archive's <a href="https://archive.org/details/winampskins">winampskins collection</a>. When we queried the Archive's search API while writing this, the collection reported 106,281 items.</p>
<p>The part we find most impressive is the fidelity. The <a href="https://docs.webamp.org/docs/features/skins/">Webamp docs</a> say the project tries to render skins "pixel for pixel" the way Winamp 2.9 did. Preserving a file is one thing. Preserving the experience of a file, with the buttons that light up when you press them, is much harder.</p>
<p><img src="https://spotube.org/images/blog/golden-age-of-media-player-skins/anim/skin-timeline.gif" alt="A horizontal timeline glowing like a CRT readout runs from 1997 to 2026, with a tiny pixel LCD counter above it. Markers pop in one at a time: April 1997 Winamp 0.20a, September 1998 Winamp 2.0 and skin docs, 2000 nearly 3,000 skins, June 2000 WMP 7 skins, August 2002 Winamp3 modern skins, December 2003 Winamp 5, November 2013 AOL announces Winamp.com shutdown, October 2018 over 5,000 skins at the Internet Archive, then a museum building icon labelled over 100,000 skins. The LCD counter rolls up from 0 to 100,000 as the markers pass. The last marker, November 10 2026, shows a small WMP skin window flickering out." /></p>
<p><em>From a menu bar in 1997 to a museum of over 100,000 skins.</em></p>
<h2>The revival is called "themes" now</h2>
<p>The urge never went away. It just changed shape. Today's players tend to offer themes instead of skins: instead of replacing every bitmap, you change colors, shapes, fonts and icons on top of an interface the app still lays out for you. That trades the freedom of a frog-shaped window for something that works at any screen size, in light and dark mode, and on a phone.</p>
<p>Spotube is one of those players. A Spotube theme is, fittingly, a zip file: a folder with a <code>theme.json</code> at its root, plus an optional logo, fonts and icons, as described in <a href="https://github.com/team-spotube/spotube/blob/master/themes/README.md"><code>themes/README.md</code></a>. It describes colors, shapes and per-component styles as data, and the app does the drawing. It will not let you cut the window into a polygon, but it does let anyone repaint the player without touching the app's code. If you want to build one, our guide to <a href="https://spotube.org/blog/make-your-own-spotube-theme">making your own Spotube theme</a> walks through it.</p>
<p>The lineage is easy to spot. A renamed zip, a fixed set of file names, a format simple enough that people with a paint program and an afternoon could make something personal. The skinners of 1999 would recognize it instantly, and then probably ask why it can't be shaped like a frog.</p>
<p>If you have an old skin of your own lying around on a backup drive, check whether the museum already has it. If it does not, upload it. Somebody made that, and it deserves to stay findable.</p>
<h2>References</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Winamp">Winamp (Wikipedia)</a>: release dates, skin counts, communities, classic versus modern skins.</li>
<li><a href="https://en.wikipedia.org/wiki/Sonique_(media_player)">Sonique (Wikipedia)</a>: history, Lycos sale, irregular skins.</li>
<li><a href="https://en.wikipedia.org/wiki/Windows_Media_Player">Windows Media Player (Wikipedia)</a>: version 7 release date, skins and visualizations.</li>
<li><a href="https://en.wikipedia.org/wiki/XMMS">XMMS (Wikipedia)</a>: the Linux player that loaded Winamp 2 skins.</li>
<li><a href="https://jordaneldredge.com/how-winamp2-js-loads-native-skins-in-your-browser/">How Winamp2-js loads native skins in your browser</a>: .wsz as renamed zip, BMP sprite sheets.</li>
<li><a href="https://jordaneldredge.com/webamp-modern/">Rendering "modern" Winamp skins in the browser</a>: .wal files, XML and MAKI.</li>
<li><a href="https://jordaneldredge.com/ia-skins/">Preserving Winamp skins for posterity at the Internet Archive</a>: how the skin collection and museum came to be.</li>
<li><a href="https://github.com/captbaritone/webamp/blob/master/packages/webamp/js/skinSprites.ts">Webamp skinSprites.ts</a>: sprite coordinates for every classic skin bitmap.</li>
<li><a href="https://github.com/captbaritone/webamp">Webamp on GitHub</a> and <a href="https://docs.webamp.org/docs/features/skins/">Webamp skin docs</a>: the reimplementation and its rendering goals.</li>
<li><a href="https://skins.webamp.org/">Winamp Skin Museum</a>: browse and play over 100,000 skins.</li>
<li><a href="https://archive.org/details/winampskins">Internet Archive winampskins collection</a> and <a href="https://blog.archive.org/2018/10/02/dont-click-on-the-llama/">Don't Click on the Llama</a>: the archive and its 2018 announcement.</li>
<li><a href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmp/skin-files">WMP SDK: Skin Files</a>: .wms definitions, art and JScript, plus the 2026 deprecation notice.</li>
<li><a href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmp/skin-definition-file-structure">WMP SDK: Skin Definition File Structure</a>: THEME, VIEW, clippingColor and image maps.</li>
<li><a href="https://learn.microsoft.com/en-us/previous-versions/aa386408(v=vs.85)">WMP SDK: Complete Code for Simple Skin</a>: packaging a skin as a renamed .wmz zip.</li>
<li><a href="https://en.wikipedia.org/wiki/ZIP_(file_format)">ZIP file format</a>, <a href="https://en.wikipedia.org/wiki/BMP_file_format">BMP file format</a> and <a href="https://en.wikipedia.org/wiki/Texture_atlas">Texture atlas</a>: background on the building blocks.</li>
<li><a href="https://github.com/team-spotube/spotube/blob/master/themes/README.md">Spotube themes README</a>: the theme package format.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://spotube.org/blog/golden-age-of-media-player-skins">spotube.org</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[MP3, AAC, Opus, FLAC: which differences can you actually hear?]]></title><description><![CDATA[Lossy vs lossless, bitrates, Opus efficiency and blind tests. What Spotube streams by default, and which differences you can actually hear.]]></description><link>https://spotube.hashnode.dev/mp3-aac-opus-flac-which-differences-can-you-actually-hear</link><guid isPermaLink="true">https://spotube.hashnode.dev/mp3-aac-opus-flac-which-differences-can-you-actually-hear</guid><category><![CDATA[audio]]></category><category><![CDATA[codecs]]></category><category><![CDATA[opus]]></category><category><![CDATA[FLAC]]></category><category><![CDATA[Spotube ]]></category><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Fri, 04 Dec 2026 03:06:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/8f8d5273-02a3-47ac-81f4-077fcc82c5f5.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Audio codecs are one of those topics where everyone has an opinion, and most of those opinions come from one listen through cheap earbuds on a noisy train. We are not going to pretend we have golden ears either. What we can do is explain how the codecs work, read the numbers, and show what Spotube actually asks for when you press play. Where we could not verify something, we say so.</p>
<h2>Lossless and lossy are different bets</h2>
<p>A digital recording (<a href="https://en.wikipedia.org/wiki/Pulse-code_modulation">PCM</a>) is just a list of numbers. <a href="https://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard)">CD audio</a> stores 44,100 samples per second for each channel, and each sample is 16 bits. For stereo that is 44,100 x 16 x 2 = 1,411,200 bits per second, or about 1411 kbps. The 44.1 kHz sample rate can represent frequencies up to 22.05 kHz, which is above what most people can hear, and the hearing of most adults tops out well below that.</p>
<p>A lossless codec like <a href="https://xiph.org/flac/">FLAC</a> looks for redundancy in those numbers, much like a zip file does, and rebuilds the exact same samples when it decodes. The file is smaller, often around 50 to 60 percent of the raw size depending on the music, and not a single sample changes.</p>
<p>A lossy codec makes a different bet. It does not try to rebuild the samples. It tries to rebuild something that sounds the same to a listener. That one sentence is the whole trick, and it is also where the arguments start.</p>
<h3>Your ears have blind spots, and codecs use them</h3>
<p>The main trick is <a href="https://en.wikipedia.org/wiki/Psychoacoustics">psychoacoustic</a> <a href="https://en.wikipedia.org/wiki/Auditory_masking">masking</a>. A loud sound makes quieter sounds that are close to it in frequency (and, to a lesser extent, in time) hard to hear. An encoder builds a rough model of this, works out a masking threshold, and spends no bits on anything that falls below it.</p>
<p><img src="https://spotube.org/images/blog/audio-codecs-what-you-can-hear/anim/masking.gif" alt="Frequency plot: a loud tone lifts a dashed masking threshold around it. Two equally quiet tones appear, one just above the loud tone in frequency and one far away. An encoder sweep drops the neighbour, which sits under the threshold and gets no bits, and keeps the distant tone, which sits above it" /></p>
<p><em>The same quiet tone is masked next to a loud one and audible far from it</em></p>
<p>The model is an approximation, and it behaves differently for different music. Dense rock mixes hide a lot of sins. A solo piano, a triangle or a single voice in a quiet room leaves very little cover, so artifacts such as <a href="https://en.wikipedia.org/wiki/Pre-echo">pre-echo</a> on sharp attacks are easier to notice. That is why the "can you hear it" answer depends on the track as much as on the codec.</p>
<h2>Bitrate is a budget, not a grade</h2>
<p>Bitrate is how many bits per second the encoder is allowed to spend. It is a useful number, but it is only comparable between codecs and encoders that are doing similar work. A modern encoder spending 128 kbps on a perceptual model can sound better than an older design at a higher bitrate, so a bitrate number on its own tells you about the size of the file more than the quality of the sound.</p>
<p><img src="https://spotube.org/images/blog/audio-codecs-what-you-can-hear/anim/bitrate.gif" alt="Bar chart with a stopwatch: for one second of audio, a CD PCM bar fills to 1411 kbps while the Spotube presets fill to 256, 128, 96 and 44 kbps. The 256 kbps default is marked, and a dimension line shows CD audio spends more than 5x its bits" /></p>
<p><em>One second of audio, five budgets</em></p>
<p>The diagram above is the budget view. Raw CD audio spends more than five times the bits of Spotube's default 256 kbps. Everything that follows is about how much of that gap you can actually hear.</p>
<h2>The codecs, one paragraph each</h2>
<h3>MP3 and AAC</h3>
<p><a href="https://en.wikipedia.org/wiki/MP3">MP3</a> (MPEG-1 Layer III) dates back to the early 1990s and is still everywhere. <a href="https://en.wikipedia.org/wiki/Advanced_Audio_Coding">AAC</a> is its successor. At the same bitrate it is generally more efficient, and it is the usual codec inside <code>.m4a</code> and MP4 files. In published listening tests, AAC at around 256 kbps is very hard for most listeners to tell apart from the original, and MP3 generally needs a higher bitrate to reach the same point. Treat "very hard to tell apart" as a statement about averages, not about your particular speakers.</p>
<h3>Opus</h3>
<p><a href="https://opus-codec.org/">Opus</a> is the codec we care about most in Spotube. It is standardized in <a href="https://www.rfc-editor.org/info/rfc6716/">RFC 6716</a> and is built to handle both speech and music. It supports frame sizes from 2.5 ms up to 60 ms, which is why it is used for low-latency voice and video calls. Internally it combines a speech-oriented layer (SILK) with a music-oriented one (CELT). For stereo music, Opus at around 96 to 128 kbps is widely regarded as a very efficient choice, and in most published comparisons it beats MP3 and AAC at the same bitrate. Opus is usually carried in an <a href="https://xiph.org/ogg/">Ogg</a> or <a href="https://en.wikipedia.org/wiki/WebM">WebM</a> container.</p>
<h3>FLAC</h3>
<p>FLAC is lossless, open, and decodes bit for bit back to the original. It has no fixed bitrate, because the size depends on how compressible the music is. It is the right choice when the file is the thing you want to keep, and a poor choice when you need small files on a slow connection.</p>
<h2>What Spotube actually asks for</h2>
<p>The defaults live in <code>UserSettings</code> in <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/settings/SettingsModels.kt"><code>spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/settings/SettingsModels.kt</code></a>. Here is what they say:</p>
<ul>
<li><code>streamingMusicFormat</code> defaults to <code>opus</code> in a <code>webm</code> container, and <code>streamingMusicQuality</code> defaults to <code>AudioQuality.Lossy(bitrate = 256_000)</code>. The comment on <code>defaultStreamingMusicFormat()</code> gives the reason for the container: opus/webm works on every platform because the players in use, <a href="https://developer.android.com/media/media3/exoplayer">ExoPlayer</a> and <a href="https://www.videolan.org/vlc/">VLC</a>, can both decode it.</li>
</ul>
<p>The built-in audio plugin is always selected, and it offers the presets 44, 96, 128 and 256 kbps for both Opus/WebM and AAC/MP4 (<code>RealNewPipeAudioAPI</code>, under <a href="https://github.com/team-spotube/spotube/tree/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/zipline/plugin_apis/newpipe_yt"><code>spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/zipline/plugin_apis/newpipe_yt/</code></a>). Every quality it lists is lossy. The bitrate is written in bits per second in code, so <code>256_000</code> means 256 kbps.</p>
<p>The plugin API describes those qualities as a sealed interface. A plugin can offer either a lossy bitrate or a lossless sample rate and channel count. This is the model, from <a href="https://github.com/team-spotube/spotube/blob/master/plugin_interfaces/src/commonMain/kotlin/org/spotube/plugin_interfaces/plugin_apis/audio/AudioModels.kt"><code>spotube/plugin_interfaces/src/commonMain/kotlin/org/spotube/plugin_interfaces/plugin_apis/audio/AudioModels.kt</code></a>:</p>
<pre><code class="language-kotlin">@Serializable
sealed interface AudioQuality {
    @Serializable
    @SerialName("lossy")
    data class Lossy(val bitrate: Int) : AudioQuality

    @Serializable
    @SerialName("lossless")
    data class Lossless(
        val sampleRate: Int,
        val channels: Int
    ) : AudioQuality
}
</code></pre>
<p>The built-in provider only lists lossy qualities today. A plugin that wants to offer FLAC can, because the lossless variants are already part of the contract.</p>
<h3>Preferences are rankings, not filters</h3>
<p>A setting like "256 kbps Opus" is a wish, not a demand. The plugin might not offer that exact stream, and the app has to pick the best one it has. The selection lives in <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/server/StreamingUrlRepository.kt"><code>spotube/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/server/StreamingUrlRepository.kt</code></a>:</p>
<pre><code class="language-kotlin">internal fun selectPreferredAudioStream(
    streams: List&lt;AudioStream&gt;,
    preferredFormat: AudioFormat,
    preferredQuality: AudioQuality): AudioStream? = streams.minWithOrNull(
    compareBy&lt;AudioStream&gt; { stream -&gt;
        formatMismatchCount(stream, preferredFormat)
    }.thenBy { stream -&gt;
        if (stream.matchesQualityType(preferredQuality)) 0 else 1
    }.thenBy { stream -&gt;
        stream.qualityDistance(preferredQuality)
    }.thenBy { stream -&gt;
        stream.channelDistance(preferredQuality)
    }
)
</code></pre>
<p>Nothing gets thrown out up front. Every candidate gets a sort key, and the lowest key wins. The keys are compared in order. First come codec and container mismatches, each counted separately. Next is whether the stream is lossy or lossless compared to what you asked for. Then comes the distance from the requested bitrate (or sample rate), and finally the channel count for lossless streams.</p>
<p>If the only stream on offer is 128 kbps Opus and you asked for 256 kbps Opus, you get the 128 kbps stream. The log records a QUALITY FALLBACK warning, and a FORMAT FALLBACK warning appears when the codec or container differs too.</p>
<p><img src="https://spotube.org/images/blog/audio-codecs-what-you-can-hear/anim/ranking.gif" alt="Ranking table: the settings want opus / webm at 256000 bps and a plugin offers aac / mp4 256000, aac / mp4 128000, opus / webm 96000 and opus / webm 128000. Each stream gets a sort key of format mismatches, quality type and bitrate distance, the rows sort, opus / webm 128000 wins with the lowest key and goes to the player, and the log shows QUALITY FALLBACK" /></p>
<p><em>An exact bitrate in the wrong format loses to the right format at a lower bitrate</em></p>
<p>With the default format, the built-in provider offers an exact opus/webm match, so the fallback path only runs when a plugin does not offer one.</p>
<h2>Lossless is for keeping, not for hearing</h2>
<p>Here is our honest take. On a phone, through typical earbuds, in a normal room, a good lossy codec at a decent bitrate is very hard to tell apart from lossless. If you are streaming on the train, the codec is rarely the weakest link in the chain.</p>
<p>Lossless matters for three other reasons.</p>
<ul>
<li><strong>Re-encoding.</strong> Every lossy generation (<a href="https://en.wikipedia.org/wiki/Generation_loss">generation loss</a>) adds its own losses. Converting a lossy file into another lossy format stacks artifacts, so keep the master in a lossless format and encode from there.</li>
<li><strong>Archiving.</strong> A library you plan to keep for twenty years should be stored in a format that will not quietly degrade, and FLAC is open and well supported.</li>
<li><strong>Processing.</strong> Mixing, sample analysis and tagging tools are happier with the exact samples.</li>
</ul>
<p>So our advice is simple. Listen with the lossy default. Keep the masters in FLAC if you have them.</p>
<h2>Test it yourself with ABX</h2>
<p>Do not trust us, or anyone else's forum post. Run an <a href="https://en.wikipedia.org/wiki/ABX_test">ABX test</a>. You hear sample A (the original), then sample B (the encoded version), then X, which is randomly either A or B. You decide whether X is A or B. Repeat it at least 16 times. Random guessing gets about half right, and 12 correct out of 16 happens by luck only about 3.8 percent of the time, so that is a reasonable bar for "I can actually tell."</p>
<p>Make the test files from the same source with <a href="https://ffmpeg.org/">ffmpeg</a>:</p>
<pre><code class="language-bash">ffmpeg -i track.flac -c:a libopus -b:a 128k track-opus-128.opus
ffmpeg -i track.flac -c:a libopus -b:a 96k track-opus-96.opus
ffmpeg -i track.flac -c:a aac -b:a 256k track-aac-256.m4a
</code></pre>
<p>Use music you know well, on the gear you actually listen with. Turn off any "enhancement" settings in the player, because they change the sound more than the codec does. If you cannot pass the test, that is useful information: the codec is good enough for you, and you can stop worrying about it.</p>
<h2>Where that leaves you</h2>
<p>Lossy codecs throw away what your ears are unlikely to miss, and modern ones are very good at it. Opus is the efficient choice for streaming, and FLAC is the one to keep when the master is the thing you care about. Spotube's defaults reflect that split: Opus at 256 kbps for streaming, and a ranking that falls back gracefully when a plugin does not offer what you asked for.</p>
<p>If you find a case where the defaults sound wrong on your setup, tell us which track and which codec, and we will look at it. The settings are there to change, and the ranking is short enough to read in one sitting.</p>
<h2>References</h2>
<ul>
<li><a href="https://www.rfc-editor.org/info/rfc6716/">RFC 6716: Definition of the Opus Audio Codec</a> is the Opus standard, including frame sizes and the SILK and CELT layers.</li>
<li><a href="https://opus-codec.org/">Opus codec site</a> covers Opus features and software, and its <a href="https://opus-codec.org/comparison/">comparison page</a> shows listening-test results against other codecs.</li>
<li><a href="https://xiph.org/flac/">FLAC</a> is the project site for the open lossless codec.</li>
<li><a href="https://en.wikipedia.org/wiki/MP3">MP3</a> and <a href="https://en.wikipedia.org/wiki/Advanced_Audio_Coding">AAC</a> give the history and design of both lossy codecs.</li>
<li><a href="https://en.wikipedia.org/wiki/Auditory_masking">Auditory masking</a> explains the psychoacoustic effect lossy encoders exploit.</li>
<li><a href="https://en.wikipedia.org/wiki/ABX_test">ABX test</a> describes the blind comparison method and its statistics.</li>
<li><a href="https://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard)">Red Book (audio CD standard)</a> lists the 44.1 kHz, 16-bit stereo format behind the 1411 kbps figure.</li>
<li><a href="https://developer.android.com/media/media3/exoplayer">Media3 ExoPlayer</a> and <a href="https://www.videolan.org/vlc/">VLC</a> are the two players Spotube uses.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://spotube.org/blog/audio-codecs-what-you-can-hear">spotube.org</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[How to see what an app sends over the internet: a beginner's guide to network inspection]]></title><description><![CDATA[Every app talks to servers, and you can watch it happen. DNS, TLS and HTTP in plain terms, what is visible without decrypting, and the tools that…]]></description><link>https://spotube.hashnode.dev/how-to-see-what-an-app-sends-over-the-internet-a-beginner-s-guide-to-network-inspection</link><guid isPermaLink="true">https://spotube.hashnode.dev/how-to-see-what-an-app-sends-over-the-internet-a-beginner-s-guide-to-network-inspection</guid><category><![CDATA[privacy]]></category><category><![CDATA[networking]]></category><category><![CDATA[Security]]></category><category><![CDATA[TLS]]></category><category><![CDATA[explainer]]></category><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Thu, 03 Dec 2026 04:38:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/d66e4f21-b76c-4c95-888e-d921d3e3cf31.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every app on your phone or laptop talks to servers. Some talk to one. Some talk to forty before you have tapped anything. You do not have to take anyone's word for which is which: with a few free tools you can watch the traffic yourself.</p>
<p>This is a beginner's guide to doing exactly that. We will start with what a request actually is, then look at what you can learn without decrypting a single byte, and finally open one request all the way up. A small warning first: the techniques here are for apps and devices you own. More on that at the end.</p>
<h2>Every request goes through three steps</h2>
<p>Think of a request as a letter passing through an old postal sorting office. Before it can be delivered, three things happen.</p>
<h3>DNS: looking up the address</h3>
<p>Apps know servers by name, like <code>api.example.com</code>, but the network routes by IP address. So the first step is a <a href="https://datatracker.ietf.org/doc/html/rfc1035">DNS</a> lookup: "what is the address for this name?" Classic DNS queries go out unencrypted, which means anyone on the path, including you on your own machine, can read the names being looked up. Some apps and browsers now use <a href="https://datatracker.ietf.org/doc/html/rfc8484">DNS over HTTPS</a>, which hides those lookups inside ordinary encrypted web traffic.</p>
<h3>TLS: sealing the envelope</h3>
<p>Next the app opens a connection and starts <a href="https://datatracker.ietf.org/doc/html/rfc8446">TLS</a>, the "S" in HTTPS. TLS does two jobs: it encrypts everything that follows, and it checks the server's certificate so the app knows it is talking to the real <code>api.example.com</code> and not an impostor.</p>
<p>Here is the catch that makes this whole post possible. The app's very first TLS message, the ClientHello, is sent before any keys exist, and it usually carries the hostname in a field called <a href="https://datatracker.ietf.org/doc/html/rfc6066">Server Name Indication</a> (SNI). Servers need it because one IP address often hosts many sites. So the name is written on the outside of the envelope, in plain view.</p>
<p>There is a newer standard, <a href="https://datatracker.ietf.org/doc/rfc9849/">TLS Encrypted Client Hello</a> (ECH, published as RFC 9849 in March 2026), that encrypts the sensitive parts of the ClientHello under the server's public key. With ECH the outer ClientHello carries innocuous values and the real name rides inside, encrypted. It is a brand new standard, so expect most traffic you capture today to still show its SNI.</p>
<h3>HTTP: the letter itself</h3>
<p>Inside the sealed envelope is the actual <a href="https://datatracker.ietf.org/doc/html/rfc9110">HTTP</a> request: a method like <code>GET</code> or <code>POST</code>, a path, headers such as <code>User-Agent</code> and <code>Authorization</code>, and maybe a body full of JSON. This is the part people usually mean by "what the app sends", and it is the part TLS hides.</p>
<p><img src="https://spotube.org/images/blog/see-what-an-app-sends-over-the-internet/anim/envelope-layers.gif" alt="An old postal sorting office desk under a green banker's lamp. A kraft paper envelope slides in from a brass pneumatic tube. Its outside shows three tags: a DNS slip reading " /></p>
<p><em>The name, size and time are on the outside. The letter is sealed inside.</em></p>
<h2>What you can see without decrypting anything</h2>
<p>It is tempting to think encrypted traffic tells you nothing. It tells you a lot. Without breaking any encryption, a capture on your own device shows:</p>
<ul>
<li><strong>Who.</strong> Hostnames from DNS queries and from SNI. If a music player you just opened contacts <code>metrics.something.net</code>, you learn that without reading a byte of the payload.</li>
<li><strong>How much.</strong> The size of every connection. Encryption hides content, not length.</li>
<li><strong>When.</strong> Timestamps on every packet. Patterns jump out quickly.</li>
</ul>
<p>A worked example. Say you leave an app idle on your desk for 10 minutes and see this:</p>
<pre><code class="language-text">host                    connections   sent      received
api.example.com         1             3 KB      41 KB
cdn.example.com         2             2 KB      8.4 MB
events.example.net      20            80 KB     6 KB
</code></pre>
<p>The CDN numbers look like content: small requests, big downloads. The third row is more interesting. Twenty connections in 10 minutes is one every 30 seconds, each sending about 4 KB (80 KB / 20) and getting almost nothing back. That shape, regular small uploads while you are not doing anything, is what <a href="https://spotube.org/blog/what-music-apps-know-about-you">telemetry</a> usually looks like. You still do not know what is in those 4 KB, but you know enough to ask a good question.</p>
<p><img src="https://spotube.org/images/blog/see-what-an-app-sends-over-the-internet/anim/pigeonholes.gif" alt="Inside the sorting office, a wall of wooden pigeonholes labelled by hostname: " /></p>
<p><em>Sorting by hostname, size and time reveals patterns without opening a thing</em></p>
<h2>The tools, from gentlest to most invasive</h2>
<h3>Browser DevTools</h3>
<p>If the "app" is a website or a web-based desktop app, start here. Every major browser has a network panel: <a href="https://developer.chrome.com/docs/devtools/network">Chrome's Network panel</a> and <a href="https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/">Firefox's Network Monitor</a> list each request with its URL, method, status, headers, size and timing, already decrypted, because the browser is the one doing the encryption. Open it, reload the page, and sort by domain. Zero setup, and often the most readable view you will ever get.</p>
<h3>Application firewalls</h3>
<p>For native apps, an application firewall tells you which program opened which connection, which a raw packet capture does not. <a href="https://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a> does this on macOS and shows an alert whenever an app wants to connect. <a href="https://github.com/evilsocket/opensnitch">OpenSnitch</a> is an interactive application firewall for Linux inspired by Little Snitch. <a href="https://safing.io/">Portmaster</a> is a free and open source application firewall for Windows and Linux. None of them decrypt traffic. They show you who, where and how much, and they let you block it, which is a great way to find out what still works when a suspicious host is cut off.</p>
<h3>PCAPdroid on Android</h3>
<p>Phones are harder because you cannot easily run a capture tool next to the app. <a href="https://emanuele-f.github.io/PCAPdroid/quick_start">PCAPdroid</a> solves this without root by using Android's VpnService: no remote VPN is created, the traffic is processed locally on the device. Its Connections tab lists each connection with the app that made it, the SNI or DNS name, and the traffic volume. It can also save a PCAP file for Wireshark.</p>
<h3>Wireshark</h3>
<p><a href="https://www.wireshark.org/">Wireshark</a> shows every packet, on every protocol, in detail. It is the microscope of this list and can feel overwhelming at first. Two display filters get you most of the way:</p>
<pre><code class="language-text">dns.qry.name
tls.handshake.extensions_server_name
</code></pre>
<p>The first shows the names your machine looked up. The second shows the SNI hostnames from TLS handshakes (both are standard fields in Wireshark's <a href="https://www.wireshark.org/docs/dfref/t/tls.html">TLS</a> and <a href="https://www.wireshark.org/docs/dfref/d/dns.html">DNS</a> filter references). Right-click either column and "Apply as Column", and you have a list of every host contacted.</p>
<p>Wireshark can even decrypt TLS without a proxy if the client cooperates. Per the <a href="https://wiki.wireshark.org/TLS">Wireshark TLS wiki</a>, Firefox, Chrome and curl write per-session secrets to a file when the <code>SSLKEYLOGFILE</code> environment variable is set, and you point Wireshark at that file. Most native apps do not support this, which is where the next tool comes in.</p>
<h3>mitmproxy</h3>
<p><a href="https://www.mitmproxy.org/">mitmproxy</a> is an intercepting proxy: the app connects to it, it connects to the real server, and it shows you everything in between, decrypted. That is a <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">man-in-the-middle</a>, done on purpose, on your own machine.</p>
<p>The trick is certificates. The first time mitmproxy runs, it creates its own <a href="https://docs.mitmproxy.org/stable/concepts/certificates/">certificate authority</a> in <code>~/.mitmproxy</code>, and uses it to generate a certificate for each site on the fly. Your device will not trust that CA until you install it, and that one step is what turns "untrusted stranger" into "proxy I chose". It is also why you should remove the CA when you are done.</p>
<h2>A worked walkthrough: opening one envelope</h2>
<p>Let's inspect one request end to end, with <code>curl</code> as our "app" and <a href="https://httpbin.org/">httpbin.org</a>, a public test service that echoes requests back, as the server. Everything runs on our own laptop.</p>
<p><strong>Step 1: the outside of the envelope.</strong> Run curl in verbose mode without any proxy:</p>
<pre><code class="language-bash">curl -v "https://httpbin.org/get?q=lofi"
</code></pre>
<p><a href="https://everything.curl.dev/usingcurl/verbose/">Verbose output</a> shows the DNS answer, the TLS handshake and the HTTP exchange. Trimmed, with the IP replaced by a documentation address:</p>
<pre><code class="language-text">* Host httpbin.org:443 was resolved.
* IPv4: 203.0.113.10
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
&gt; GET /get?q=lofi HTTP/2
&gt; Host: httpbin.org
&gt; User-Agent: curl/8.18.0
&lt; HTTP/2 200
&lt; content-type: application/json
</code></pre>
<p>curl can print the lines starting with <code>&gt;</code> because it is the client and holds the keys. A Wireshark capture of the same request on the wire would show you the DNS query for <code>httpbin.org</code>, the ClientHello with SNI <code>httpbin.org</code>, and then a few kilobytes of encrypted records. Notice what is missing from the wire view: the path <code>/get?q=lofi</code>. Query strings travel inside the encrypted HTTP request, not on the envelope.</p>
<p><strong>Step 2: open it.</strong> Start <code>mitmproxy</code> with no arguments. By default it <a href="https://docs.mitmproxy.org/stable/overview/getting-started/">listens on port 8080</a>. Now send the same request through it, telling curl to trust mitmproxy's CA just for this command, so nothing on the system changes:</p>
<pre><code class="language-bash">curl --proxy http://127.0.0.1:8080 \
     --cacert ~/.mitmproxy/mitmproxy-ca-cert.pem \
     "https://httpbin.org/get?q=lofi"
</code></pre>
<p>The flow appears in mitmproxy's list. Select it and you see the full request: method <code>GET</code>, path <code>/get?q=lofi</code>, every header, then the full JSON response. For a real app you would point it at the same proxy and install the CA on that device, and the flow list becomes a reading of everything the app says.</p>
<p><strong>Step 3: ask questions.</strong> For every flow, check: Is this host expected? Does the body contain anything that identifies me or my device? Does it happen when I do something, or on a timer? Three questions, and most surprises surface.</p>
<h2>Certificate pinning: why some apps refuse your proxy</h2>
<p>Try the same with some apps and you will get connection errors instead of flows. Usually that is one of two things.</p>
<p>First, modern Android is strict by default. Per the <a href="https://developer.android.com/privacy-and-security/security-config">Android network security configuration docs</a>, apps targeting Android 7.0 (API level 24) and higher trust only the pre-installed system CAs unless they opt in, while apps targeting API level 23 and lower also trust user-added CAs. Installing mitmproxy's CA in your phone's settings makes it a user-added CA, so most current apps simply ignore it. PCAPdroid's <a href="https://emanuele-f.github.io/PCAPdroid/tls_decryption">TLS decryption guide</a> is honest about this: TLS decryption on Android is not easy, and many apps will not cooperate.</p>
<p>Second, some apps go further and use <a href="https://community.owasp.org/controls/Certificate_and_Public_Key_Pinning">certificate pinning</a>: they ship with the expected public key (or its hash) and reject any chain that does not include it, even one your device fully trusts. The goal is to survive a hostile network, which is exactly the situation a proxy imitates. Pinning has real costs too: a key rotation without a backup pin can lock users out until an app update ships, and OWASP's guide argues that in nearly all cases pinning creates more risk than reward. Plenty of apps still use it.</p>
<p><img src="https://spotube.org/images/blog/see-what-an-app-sends-over-the-internet/anim/pinned-door.gif" alt="A brass inspection desk with two envelopes arriving. mitmproxy, drawn as a clerk with a brass stamp, reseals each opened envelope with its own green wax seal labelled " /></p>
<p><em>A trusted CA is not enough when the app expects one specific key</em></p>
<p>We are not going to explain how to defeat pinning in apps you did not write. If an app pins, you still have the outside of the envelope: hosts, sizes and timing from PCAPdroid, Wireshark or a firewall. mitmproxy even suggests using <code>ignore_hosts</code> for pinned domains so you can inspect the rest. If you need more than that for an app, the respectful route is to ask its developers, or to pick software whose source you can read.</p>
<p>For the record, here is how Spotube looks from this side of the desk. We searched our code and found no certificate pinning, and our <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/androidMain/AndroidManifest.xml">Android manifest</a> does not set a custom network security config. Our Android build targets API level 37, so on a phone it follows the platform default above and ignores user-added CAs. The easiest way to watch Spotube's traffic is the desktop build on your own machine, starting from <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/network/HttpClientFactory.kt"><code>HttpClientFactory.kt</code></a>, the one place the app builds its HTTP clients.</p>
<h2>Inspect only what you own</h2>
<p>The rule is simple: inspect apps on devices you own, or have explicit permission to test. Capturing other people's traffic on a shared network, a workplace or a café is a different activity, and in many places an illegal one. A proxy that decrypts traffic also sees passwords and session tokens in clear text, so treat capture files like secrets, and uninstall any CA you added once you are finished.</p>
<p>There is a flip side for developers. Anything an app sends can be read, replayed and forged by the person holding the device. That is why servers should never trust a client just because it is "their" app, a lesson we took seriously when we built Group Jam and wrote about how we <a href="https://spotube.org/blog/treat-every-peer-as-hostile">treat every peer as hostile</a>.</p>
<p>Start small. Open DevTools on a website you use daily, sort by domain, and count the hosts. The number is usually a conversation starter.</p>
<h2>References</h2>
<ul>
<li><a href="https://datatracker.ietf.org/doc/html/rfc1035">RFC 1035: Domain names, implementation and specification</a>: the DNS protocol.</li>
<li><a href="https://datatracker.ietf.org/doc/html/rfc8484">RFC 8484: DNS Queries over HTTPS</a>: DNS lookups carried inside HTTPS.</li>
<li><a href="https://datatracker.ietf.org/doc/html/rfc8446">RFC 8446: TLS 1.3</a>: the handshake and encryption behind HTTPS.</li>
<li><a href="https://datatracker.ietf.org/doc/html/rfc6066">RFC 6066: TLS Extensions</a>: defines Server Name Indication.</li>
<li><a href="https://datatracker.ietf.org/doc/rfc9849/">RFC 9849: TLS Encrypted Client Hello</a>: encrypting the ClientHello, including the real hostname.</li>
<li><a href="https://datatracker.ietf.org/doc/html/rfc9110">RFC 9110: HTTP Semantics</a>: methods, headers and status codes.</li>
<li><a href="https://developer.chrome.com/docs/devtools/network">Chrome DevTools: Network panel</a> and <a href="https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/">Firefox Network Monitor</a>: browser network inspection.</li>
<li><a href="https://www.wireshark.org/">Wireshark</a>, its <a href="https://wiki.wireshark.org/TLS">TLS wiki page</a> and the <a href="https://www.wireshark.org/docs/dfref/t/tls.html">TLS</a> and <a href="https://www.wireshark.org/docs/dfref/d/dns.html">DNS</a> filter references: packet capture, key log decryption and display filters.</li>
<li><a href="https://www.mitmproxy.org/">mitmproxy</a>, <a href="https://docs.mitmproxy.org/stable/overview/getting-started/">Getting started</a> and <a href="https://docs.mitmproxy.org/stable/concepts/certificates/">About certificates</a>: the intercepting proxy, its default port, its CA and its notes on pinning.</li>
<li><a href="https://emanuele-f.github.io/PCAPdroid/quick_start">PCAPdroid quick start</a> and <a href="https://emanuele-f.github.io/PCAPdroid/tls_decryption">TLS decryption</a>: rootless capture on Android and its limits.</li>
<li><a href="https://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a>, <a href="https://github.com/evilsocket/opensnitch">OpenSnitch</a> and <a href="https://safing.io/">Portmaster</a>: application firewalls for macOS, Linux and Windows.</li>
<li><a href="https://developer.android.com/privacy-and-security/security-config">Android network security configuration</a>: default trust anchors and pinning on Android.</li>
<li><a href="https://community.owasp.org/controls/Certificate_and_Public_Key_Pinning">OWASP: Certificate and Public Key Pinning</a>: what pinning is and its trade-offs.</li>
<li><a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">Man-in-the-middle attack</a>: background on the technique a proxy uses.</li>
<li><a href="https://everything.curl.dev/usingcurl/verbose/">Everything curl: verbose</a> and <a href="https://httpbin.org/">httpbin</a>: the client and test server from the walkthrough.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://spotube.org/blog/see-what-an-app-sends-over-the-internet">spotube.org</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Open-source licenses in plain English: MIT, Apache 2.0, GPL and AGPL]]></title><description><![CDATA[What MIT, Apache 2.0, GPL and AGPL actually ask of you, why GPLv2 and Apache don't mix, what the SaaS loophole is, and why Spotube ships under…]]></description><link>https://spotube.hashnode.dev/open-source-licenses-in-plain-english-mit-apache-2-0-gpl-and-agpl</link><guid isPermaLink="true">https://spotube.hashnode.dev/open-source-licenses-in-plain-english-mit-apache-2-0-gpl-and-agpl</guid><category><![CDATA[Open Source]]></category><category><![CDATA[licensing]]></category><category><![CDATA[agpl]]></category><category><![CDATA[gpl]]></category><category><![CDATA[explainer]]></category><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Wed, 02 Dec 2026 11:02:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/cc3b449e-a913-45de-ae48-98bdd6a6f404.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every open-source repo has a file most people never open: <code>LICENSE</code>. It is the only reason you are allowed to copy that code at all. Without it, default copyright applies and the code is "look, don't touch", no matter how public the repo is.</p>
<p>We get questions about ours fairly often, usually some version of "why AGPL and not MIT?". So here is the guide we wish we had when we started: what the big four licenses actually ask of you, where they clash, and why Spotube ended up where it did.</p>
<p>One thing before we start: <strong>this is not legal advice.</strong> We are developers who have read these licenses more times than is healthy, not lawyers. If real money or a real product depends on the answer, ask one.</p>
<h2>Two families: permissive and copyleft</h2>
<p>Almost every popular license falls into one of two families, and the split comes down to one question: <strong>what happens when you pass the code on?</strong></p>
<p>A <a href="https://en.wikipedia.org/wiki/Permissive_software_license">permissive license</a> says: do what you want, keep our name on it, don't sue us. You can take MIT code, change it, close it up and sell a proprietary product. The original authors get credit and nothing else.</p>
<p>A <a href="https://en.wikipedia.org/wiki/Copyleft">copyleft</a> license says: do what you want, but if you hand your version to someone else, they get the same freedoms you got. The source code and the license travel with the program. You can't take GPL code, improve it and give people only a binary.</p>
<p>Neither family is "more open". They just protect different people. Permissive licenses maximize freedom for the next developer. Copyleft licenses protect the freedom of the end user, even against that next developer.</p>
<p><img src="https://spotube.org/images/blog/open-source-licenses-explained/anim/license-families.gif" alt="Flat-lay of a desk with three manila folders side by side. A red rubber stamp hits the first folder with PERMISSIVE, and two cream sheets labelled MIT and Apache-2.0 slide into it. A blue stamp marks the second folder COPYLEFT and sheets labelled GPL-2.0 and GPL-3.0 slide in. A second blue stamp marks the third folder NETWORK and one sheet labelled AGPL-3.0 slides in. Under each folder an index card lists the duties, earlier duties appearing as carbon copies and the new one typed fresh: under PERMISSIVE " /></p>
<p><em>Each folder keeps everything the one before it asks, and adds one more duty.</em></p>
<h2>What each license actually requires</h2>
<h3>MIT: keep the notice</h3>
<p>The <a href="https://opensource.org/license/mit">MIT License</a> is about 170 words. It grants permission "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software" on one condition: "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software." Then comes the all caps "AS IS" warranty disclaimer.</p>
<p>That's it. Ship a minified bundle with MIT code inside? Keep the notice somewhere in it (that's why so many apps have an "open source licenses" screen). The FSF's <a href="https://www.gnu.org/licenses/license-list.html#Expat">license list</a> calls it "a lax, permissive non-copyleft free software license, compatible with the GNU GPL".</p>
<h3>Apache 2.0: notice, changes, and patents</h3>
<p>The <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a> is permissive too, but longer and more careful. Section 4 asks you to give recipients a copy of the license, to make "any modified files to carry prominent notices stating that You changed the files", and to keep existing copyright, patent, trademark and attribution notices (including a <code>NOTICE</code> file if the project has one).</p>
<p>The big difference is section 3, the <strong>patent grant</strong>. Every contributor gives you a "perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable" license to any of their patents that their contribution infringes. MIT says nothing explicit about patents.</p>
<p>There is a sting in the tail. If you sue anyone claiming the project infringes your patent, "any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed." It works like a peace treaty: use our patents freely, but if you start a patent war over this code, you lose your shield.</p>
<h3>GPL: share the source when you distribute</h3>
<p>The <a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GPL version 3</a> (dated 29 June 2007) is the classic copyleft license. Run it, study it, change it, all fine. The obligations kick in when you <strong>convey</strong> the program, meaning you give copies to someone else. Then you must pass on the GPL itself and provide the "Corresponding Source", the full source needed to build and modify the version you shipped.</p>
<p>The license gives you several ways to do that. Ship the source next to the binary, host it on a server, or, for physical products, include a written offer "valid for at least three years" to provide it later.</p>
<p>What the GPL does <strong>not</strong> do is make you publish anything you never distribute. The official <a href="https://www.gnu.org/licenses/gpl-faq.html#GPLRequireSourcePostedPublic">GPL FAQ</a> is blunt: "You are free to make modifications and use them privately, without ever releasing them," and that applies to companies using a modified version internally too.</p>
<h3>AGPL: share the source with network users too</h3>
<p>The <a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU Affero GPL version 3</a> is the GPLv3 plus one extra clause. The FSF describes it as "the terms of GPLv3, with an additional paragraph in section 13". Here is the heart of section 13:</p>
<blockquote>
<p>if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version</p>
</blockquote>
<p>Read it slowly, because every phrase matters. It applies when <strong>you modify</strong> the program. It covers users <strong>interacting remotely</strong>, not people who never touch your server. And you satisfy it by <strong>offering</strong> the source, typically through a link in the interface. The <a href="https://www.gnu.org/licenses/gpl-faq.html#AGPLv3InteractingRemotely">GPL FAQ</a> says programs "expressly designed to accept user requests and send responses over a network" qualify, such as "web and mail servers, interactive web-based applications, and servers for games that are played online."</p>
<p>To see why anyone would want that clause, we need to talk about the loophole it closes.</p>
<h2>The SaaS loophole, and why AGPL exists</h2>
<p>The GPL's trigger is distribution. That made sense when software meant a program on your own computer. Then the web happened, and lots of programs stopped being distributed at all. You don't download a webmail service; you send requests to a server and get pages back.</p>
<p>The GNU project's own explainer, <a href="https://www.gnu.org/licenses/why-affero-gpl.html">Why the Affero GPL</a>, walks through it with a developer called D. You release a server program under the GPL. D modifies it, "might very likely run it on his own server and never release copies. Then you would never get a copy of the source code of his version". D never conveyed anything, so the GPL never asked for anything. D's users get HTML, you get nothing back.</p>
<p><img src="https://spotube.org/images/blog/open-source-licenses-explained/anim/saas-loophole.gif" alt="Three rows of carbon copies on a desk, each starting from a folder labelled " /></p>
<p><em>The GPL triggers on copies. AGPL section 13 also triggers on network users of modified versions.</em></p>
<p>The same essay gives the AGPL version of the story: "If D runs his version on a server that everyone can use, you too can use it," download the source, and merge his changes back.</p>
<p>The idea is older than the GNU license. According to <a href="https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License">Wikipedia's history of the AGPL</a>, Affero, Inc. published the original Affero GPL in March 2002, and the FSF published the GNU AGPLv3 on November 19, 2007. Spotube's own <code>LICENSE</code> file carries that date right under its title: "Version 3, 19 November 2007".</p>
<h2>Compatibility: when licenses can't share a file</h2>
<p>Licenses don't only govern what you owe. They decide what you can <strong>combine</strong>. A combined copyleft work has to go out under the copyleft license, so every piece in it must allow that. If one piece adds a requirement the copyleft license forbids, the combination can't legally be distributed.</p>
<p>The classic example is Apache 2.0 and GPLv2. The FSF says Apache 2.0 is "compatible with version 3 of the GNU GPL" but "not compatible with GPL version 2, because it has some requirements that are not in that GPL version. These include certain patent termination and indemnification provisions." The Apache Software Foundation agrees on its <a href="https://www.apache.org/licenses/GPL-compatibility.html">GPL compatibility page</a>: "Apache 2 software can therefore be included in GPLv3 projects", but the FSF "has never considered the Apache License to be compatible with GPL version 2".</p>
<p>So the version wording in a header matters a lot. A quick cheat sheet:</p>
<table>
<thead>
<tr>
<th>You want to combine</th>
<th>Into</th>
<th>Works?</th>
</tr>
</thead>
<tbody><tr>
<td>MIT</td>
<td>anything (keep the notice)</td>
<td>yes</td>
</tr>
<tr>
<td>Apache-2.0</td>
<td>GPL-3.0 or AGPL-3.0</td>
<td>yes</td>
</tr>
<tr>
<td>Apache-2.0</td>
<td>GPL-2.0-only</td>
<td>no</td>
</tr>
<tr>
<td>GPL-2.0-or-later</td>
<td>GPL-3.0</td>
<td>yes, by picking v3</td>
</tr>
<tr>
<td>GPL-3.0</td>
<td>a project you want to keep MIT-only</td>
<td>no, the combined work must be GPL</td>
</tr>
</tbody></table>
<p>That "or later" row is worth pausing on. GNU-style license notices (Spotube's is quoted further down) name a version and then add "or (at your option) any later version." For a <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GPLv2</a> project, keeping that phrase means the code can move to v3 when it needs to; deleting it makes the project GPL-2.0-only. That one sentence decides whether a project can absorb Apache code a decade later.</p>
<p><img src="https://spotube.org/images/blog/open-source-licenses-explained/anim/compatibility.gif" alt="A desk with two license cards on pads of carbon copies, MIT and Apache-2.0, and four docket cards: GPL-2.0-only, GPL-3.0, AGPL-3.0 and GPL-2.0-or-later. A carbon copy of MIT is clipped into every docket, each paper clip turning green with " /></p>
<p><em>Apache-2.0 fits into GPLv3 but not GPLv2-only. 'Or later' is the escape hatch.</em></p>
<h2>SPDX: one line instead of a paragraph</h2>
<p>Long license headers are hard for tools to read and easy to mangle. <a href="https://spdx.org/licenses/">SPDX</a> is a standard list of short license identifiers: <code>MIT</code>, <code>Apache-2.0</code>, <code>GPL-2.0-only</code>, <code>GPL-3.0-or-later</code>, <code>AGPL-3.0-or-later</code>, and hundreds more. Notice that "only" and "or later" are part of the identifier, which bakes in the compatibility point above.</p>
<p>The SPDX project's <a href="https://spdx.dev/learn/handling-license-info/">guide to handling license info</a> shows the convention: "Adding an SPDX ID only requires adding a single <code>SPDX-License-Identifier:</code> line." Expressions work too, like <code>MIT OR Apache-2.0</code> for dual licensing. Scanners, package managers and compliance tools can read these without a human squinting at prose.</p>
<pre><code class="language-kotlin">/* Copyright (C) 2026 Kingkor Roy Tirtho and Spotube Contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
</code></pre>
<p>That is the top of a real file in Spotube, <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/core/ui/component/cards/MediaEmptyState.kt"><code>MediaEmptyState.kt</code></a>.</p>
<h2>Common myths</h2>
<p><strong>"You can't sell GPL software."</strong> You can. The <a href="https://www.gnu.org/licenses/gpl-faq.html#DoesTheGPLAllowMoney">GPL FAQ</a> says "Yes, the GPL allows everyone to do this," and the GNU essay on <a href="https://www.gnu.org/philosophy/selling.html">selling free software</a> says you can charge "nothing, a penny, a dollar, or a billion dollars." The catch is commercial, not legal: each buyer gets the source and the right to share it, so selling copies is hard to scale.</p>
<p><strong>"AGPL applies the moment you run it."</strong> Private use triggers nothing. Section 13 starts with "if you modify the Program", and it is about other people interacting with your modified version over a network. Running unmodified AGPL software on your own server, or a modified copy only you use, does not create a duty to offer source to anyone. (Distributing copies still brings in the normal GPL rules, of course.)</p>
<p><strong>"MIT means no rules."</strong> Dropping the copyright notice is the one thing MIT forbids, and it is the most common way people break it.</p>
<p><strong>"Public repo means open source."</strong> No license file, no permission. Public visibility and a license grant are different things.</p>
<h2>Why Spotube uses AGPL</h2>
<p>Spotube's <a href="https://github.com/team-spotube/spotube/blob/master/LICENSE"><code>LICENSE</code></a> is the full GNU AGPL version 3 text, and the README states it as AGPL-3.0-or-later. Most source files carry the long-form notice from <a href="https://github.com/team-spotube/spotube/blob/master/.github/agpl_header.txt"><code>.github/agpl_header.txt</code></a>:</p>
<pre><code class="language-text">Copyright (C) 2026 Kingkor Roy Tirtho and Spotube Contributors

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
</code></pre>
<p>We don't add those headers by hand. Our <a href="https://github.com/team-spotube/spotube/blob/master/lefthook.yaml"><code>lefthook.yaml</code></a> pre-commit hook runs Google's <a href="https://github.com/google/addlicense">addlicense</a> on staged <code>kt</code>, <code>kts</code>, <code>xml</code>, <code>yaml</code> and <code>yml</code> files with that header as the template, so new files get it before they reach the repo. A few dozen newer files use the short SPDX form shown earlier instead.</p>
<p>Why AGPL for a music app that runs on your own device? Spotube is a client, so for the app itself, AGPL behaves almost exactly like GPLv3: if you ship a modified build, you ship the source. Section 13 is about the future. Music apps are full of logic that could be lifted into a hosted service: playlists, search, plugin plumbing. AGPL means that if someone does that with a modified version of our code, their users can still get the source. For a project that runs on volunteer time and donations (we wrote about that in <a href="https://spotube.org/blog/open-source-solo-maintainer-sustainability">keeping an open-source app alive as a solo maintainer</a>), that reciprocity is the deal we want: take it, improve it, and share the improvements back.</p>
<p>The "or later" choice is about the future too. If the FSF ever publishes an AGPLv4, people can use Spotube under it without us chasing every past contributor for permission.</p>
<h2>Picking a license for your own project</h2>
<p>A rough rule of thumb, not legal advice: if you want maximum adoption, including inside closed products, pick MIT or Apache 2.0, and prefer Apache when patents could ever matter. If you want improvements to come back, pick GPLv3. If your code is likely to run on someone else's server, pick AGPLv3. Whatever you pick, put an SPDX line in each file, a full <code>LICENSE</code> at the root, and say "or later" on purpose, not by accident.</p>
<h2>References</h2>
<ul>
<li><a href="https://opensource.org/license/mit">The MIT License (Open Source Initiative)</a>: the full license text.</li>
<li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>: sections 3 (patent grant and termination) and 4 (redistribution).</li>
<li><a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU General Public License v3</a>: conveying, Corresponding Source and the written offer.</li>
<li><a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License v2</a>: the older version and its "any later version" wording.</li>
<li><a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License v3</a>: section 13, remote network interaction.</li>
<li><a href="https://www.gnu.org/licenses/why-affero-gpl.html">Why the Affero GPL</a>: the GNU project's explanation of the server problem.</li>
<li><a href="https://www.gnu.org/licenses/license-list.html">Various Licenses and Comments about Them (FSF)</a>: compatibility notes for MIT, Apache 2.0 and AGPL.</li>
<li><a href="https://www.apache.org/licenses/GPL-compatibility.html">Apache License v2.0 and GPL Compatibility</a>: the ASF's side of the GPLv2 story.</li>
<li><a href="https://www.gnu.org/licenses/gpl-faq.html">Frequently Asked Questions about the GNU Licenses</a>: private modification, selling, and what counts as remote interaction.</li>
<li><a href="https://www.gnu.org/philosophy/selling.html">Selling Free Software</a>: why charging for copies is allowed.</li>
<li><a href="https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License">GNU Affero General Public License (Wikipedia)</a>: history from Affero, Inc. in 2002 to GNU AGPLv3 in 2007.</li>
<li><a href="https://en.wikipedia.org/wiki/Permissive_software_license">Permissive software license (Wikipedia)</a> and <a href="https://en.wikipedia.org/wiki/Copyleft">Copyleft (Wikipedia)</a>: background on the two families.</li>
<li><a href="https://spdx.org/licenses/">SPDX License List</a> and <a href="https://spdx.dev/learn/handling-license-info/">Handling License Info (SPDX)</a>: identifiers and the one-line header convention.</li>
<li><a href="https://github.com/google/addlicense">google/addlicense</a>: the tool that adds license headers to source files.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://spotube.org/blog/open-source-licenses-explained">spotube.org</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Building albums and artists out of messy music tags]]></title><description><![CDATA[How Spotube's local library turns messy file tags into albums and artists: trimming, case folding, multi-artist credits, cover picking and local…]]></description><link>https://spotube.hashnode.dev/building-albums-and-artists-out-of-messy-music-tags</link><guid isPermaLink="true">https://spotube.hashnode.dev/building-albums-and-artists-out-of-messy-music-tags</guid><category><![CDATA[Kotlin]]></category><category><![CDATA[compose multiplatform]]></category><category><![CDATA[metadata]]></category><category><![CDATA[Spotube ]]></category><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Wed, 02 Dec 2026 11:02:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/e7795f0c-82d7-4753-9216-6e53ef519d71.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every music file carries a small envelope of metadata. Title, artist, album, maybe a cover image. In theory it is tidy. In practice, one album can show up as <code>Greatest Hits</code>, <code>greatest hits </code> (with a trailing space) and <code>GREATEST HITS</code> in the same folder, and nobody agrees on how to write a <a href="https://musicbrainz.org/doc/Style/Artist_Credits">collab credit</a>.</p>
<p>The local library in Spotube has to show albums and artists for files that nobody on our side ever tagged. Nothing on disk says "this is an album". The app builds those groups itself, from whatever the <a href="https://en.wikipedia.org/wiki/ID3">tags</a> happen to say. This post walks through how that works, and the places where we had to accept that the result is only as good as the tags.</p>
<h2>Where the groups come from</h2>
<p>The raw material is the local media index. <code>LocalMediaCollectionsRepository</code> sits on top of <code>LocalMediaLibraryCoordinator</code> and exposes three flows: the flat track list, the albums and the artists. All three are derived from the index and computed on <a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html"><code>Dispatchers.Default</code></a>. Each one stays active for five seconds after its last collector leaves.</p>
<pre><code class="language-kotlin">// modules/library/local/LocalMediaCollectionsRepository.kt (trimmed)
class LocalMediaCollectionsRepository(
    coordinator: LocalMediaLibraryCoordinator
) {
    private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

    val tracks: StateFlow&lt;List&lt;LocalMediaTrack&gt;&gt; = coordinator.cacheState
        .map { cache -&gt; distinctLocalFiles(cache.folders.flatMap { it.tracks }) }
        .stateIn(scope, SharingStarted.WhileSubscribed(5_000), emptyList())

    val albums: StateFlow&lt;List&lt;LocalMediaAlbum&gt;&gt; = tracks
        .map(::buildLocalAlbums)
        .stateIn(scope, SharingStarted.WhileSubscribed(5_000), emptyList())

    val artists: StateFlow&lt;List&lt;LocalMediaArtist&gt;&gt; = tracks
        .map(::buildLocalArtists)
        .stateIn(scope, SharingStarted.WhileSubscribed(5_000), emptyList())
}
</code></pre>
<p><a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalMediaCollectionsRepository.kt">View <code>LocalMediaCollectionsRepository.kt</code> on GitHub</a></p>
<p>The grouping itself lives in <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalMediaCollections.kt"><code>LocalMediaCollections.kt</code></a> as plain functions, <code>buildLocalAlbums</code> and <code>buildLocalArtists</code>. They take a list and return a list, with no Android context, no Compose and no coroutines. That is why <code>LocalMediaCollectionsTest</code> can check the grouping rules on a plain JVM without a device.</p>
<p>One detail to know about: the same file can be visible through two URIs. On Android it can be a <a href="https://developer.android.com/reference/android/provider/MediaStore">MediaStore</a> URI and a <a href="https://developer.android.com/guide/topics/providers/document-provider">Storage Access Framework</a> document URI at the same time. <code>distinctLocalFiles</code>, which sits next to the repository in <a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalMediaCollectionsRepository.kt"><code>LocalMediaCollectionsRepository.kt</code></a>, collapses those into one track and keeps every spelling in its <code>aliases</code>. <code>indexByReferencePath</code> maps each spelling back to that track, so a playlist that stores either URI still resolves.</p>
<h2>Albums: one key, a lot of spellings</h2>
<p>An album is any non-blank <code>album</code> tag. The grouping key is the trimmed, lowercased name. The first spelling we see becomes the display name.</p>
<pre><code class="language-kotlin">// modules/library/local/LocalMediaCollections.kt (trimmed)
fun buildLocalAlbums(tracks: List&lt;LocalMediaTrack&gt;): List&lt;LocalMediaAlbum&gt; {
    val byName = LinkedHashMap&lt;String, Pair&lt;String, MutableList&lt;LocalMediaTrack&gt;&gt;&gt;()
    tracks.forEach { track -&gt;
        val displayName = track.album?.trim()?.takeIf { it.isNotBlank() } ?: return@forEach
        val key = normalizeGroupKey(displayName)
        byName.getOrPut(key) { displayName to mutableListOf() }.second.add(track)
    }
    return byName.map { (key, pair) -&gt;
        val (displayName, groupTracks) = pair
        val sorted = groupTracks.sortedBy { it.name.trim().lowercase() }
        LocalMediaAlbum(
            key = key,
            name = displayName,
            tracks = sorted,
            coverBytes = sorted.firstNotNullOfOrNull { it.coverBytes?.takeIf { c -&gt; c.isNotEmpty() } })
    }.sortedBy { it.name.lowercase() }
}
</code></pre>
<p><a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalMediaCollections.kt">View <code>LocalMediaCollections.kt</code> on GitHub</a></p>
<p>Blank album tags are skipped. Those tracks still show up in the flat track list, they just do not form an album. The test <code>tracksAreGroupedByAlbumNameCaseInsensitively</code> covers the three spellings from the intro, including the trailing-space one, and checks that the first casing wins.</p>
<p><img src="https://spotube.org/images/blog/albums-and-artists-from-messy-tags/anim/albums.gif" alt="Three record sleeves carry the album tags Greatest Hits, greatest hits with a trailing space, and GREATEST HITS. Each tag is trimmed and lowercased into the same key, greatest hits, and all three records are filed behind one crate divider labelled Greatest Hits, the first spelling seen, with a sticker reading 3 tracks" /></p>
<p><em>Three spellings, one key, one album</em></p>
<p>There is a catch we want to be upfront about. The key is only the album tag. <code>LocalTrackTags</code> carries <code>title</code>, <code>artists</code>, <code>album</code> and a few numbers, but no album artist field feeds the key. So two unrelated records that are both called <code>Greatest Hits</code> end up as one album in the library. That is the trade-off for a grouping rule you can explain in one sentence. If your library looks odd, check the album tags first.</p>
<h2>Artists: multi-credit tracks belong to everyone</h2>
<p>Artist tags are the more interesting part. The native tag reader hands over all the credits of a track as one string, joined with <code>"; "</code>. <code>LocalTrackTags.toTrack</code> then splits that string on <code>;</code>, trims each piece and drops the blanks. A track tagged <code>A; B</code> ends up with the artists <code>["A", "B"]</code>.</p>
<pre><code class="language-kotlin">// modules/library/local/LocalMediaCollections.kt (trimmed)
tracks.forEach { track -&gt;
    val artists = track.artists.mapNotNull { it.trim().takeIf { name -&gt; name.isNotBlank() } }
    if (artists.isEmpty()) return@forEach
    val distinct = artists.distinctBy { normalizeGroupKey(it) }
    distinct.forEach { artistName -&gt;
        val key = normalizeGroupKey(artistName)
        byName.getOrPut(key) { artistName to mutableListOf() }.second.add(track)
    }
}
</code></pre>
<p><a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalMediaCollections.kt">View <code>LocalMediaCollections.kt</code> on GitHub</a></p>
<p>Every credited artist gets the track. Across tracks, the casing merges for free because the key is the same. The test <code>artistGroupsCoverEveryCreditedArtistWithoutDuplicates</code> checks that case: one track credited to <code>A</code> and <code>B</code>, another credited to <code>B</code> and <code>a</code>, and a third credited to <code>B</code> alone. The artist <code>A</code> gets the first two tracks, and <code>B</code> gets all three.</p>
<p>Inside one track, <code>distinctBy</code> on the normalized key also collapses case-only repeats, so <code>B</code> and <code>b</code> in the same tag count as one credit. No test isolates that case yet, so read it as the current behavior rather than a guarantee.</p>
<p><img src="https://spotube.org/images/blog/albums-and-artists-from-messy-tags/anim/artists.gif" alt="Three records carry the artist tags A; B, then B; a, then B. Each tag splits on the semicolon into separate credits, and a copy of the record is filed behind every credited artist divider. The lowercase a lands under A, so A ends up with 2 tracks and B with 3" /></p>
<p><em>Every credited artist gets the track</em></p>
<p>Artist track lists are also deduplicated by file path before sorting, so a single physical file cannot appear twice under the same artist.</p>
<h2>Covers: first alphabetical track with art</h2>
<p>Each album and artist needs one cover, and the rule is deliberately boring. Sort the group's tracks by name, then take the first track that has embedded art. Empty byte arrays count as "no art", so an empty image never wins the cover slot. <code>emptyCoversAreTreatedAsMissing</code> pins that down.</p>
<p>Picking the most common image would mean comparing bytes across every track in a group, and the answer would still shift with whatever happens to be indexed at the moment. Alphabetical order is predictable. You can read the test <code>albumCoverComesFromTheFirstAlphabeticalTrackThatHasArt</code> and know exactly which image will show up.</p>
<h2>Navigation ids are just names</h2>
<p>Albums and artists have no database id. The route is built from the normalized key: <code>Routes.LocalAlbum(album.key)</code> and <code>Routes.LocalArtist(artist.key)</code>, the same stateless pattern as <code>Routes.LocalFolder(path)</code>. When the screen opens, its view model collects <code>albumFlow(key)</code> or <code>artistFlow(key)</code>. Those flows re-emit whenever the index changes and emit <code>null</code> while the album is not indexed, so an open screen follows the library instead of holding a stale copy. On <code>null</code>, the screen shows a not-found state.</p>
<h2>Local playlists are one JSON document</h2>
<p>Playlists that only reference on-device files are a different beast. They do not go in the index and they do not live on a server. <code>LocalPlaylistRepository</code> keeps the whole list as one JSON string under a single key inside a <a href="https://developer.android.com/topic/libraries/architecture/datastore">Preferences DataStore</a> file, <code>spotube_local_playlists.preferences_pb</code>.</p>
<p>Each playlist is a small data class. Tracks are not copied in. A playlist only stores the paths, in the order the user picked them:</p>
<pre><code class="language-kotlin">// modules/library/local/LocalPlaylistModels.kt (trimmed)
@Serializable
data class LocalPlaylist(
    val id: String,
    val name: String,
    val description: String? = null,
    val coverBase64: String? = null,
    val trackPaths: List&lt;String&gt; = emptyList(),
    val createdAtEpochMs: Long = 0)
</code></pre>
<p><a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalPlaylistModels.kt">View <code>LocalPlaylistModels.kt</code> on GitHub</a></p>
<p>Ids start with <code>local:</code> so they can never collide with online playlist ids. A file that disappears is not removed from the playlist. The playlist view skips its path until the file is indexed again, and <code>remapMovedTracks</code> rewrites the stored paths when a move is detected.</p>
<p>Every write goes through one private function that reads the whole document, transforms it and writes it back inside a single <code>edit</code> block:</p>
<pre><code class="language-kotlin">// modules/library/local/LocalPlaylistRepository.kt (trimmed)
private suspend fun mutate(transform: (List&lt;LocalPlaylist&gt;) -&gt; List&lt;LocalPlaylist&gt;) {
    store.edit { prefs -&gt;
        val current = prefs[DatabaseKeys.LOCAL_PLAYLISTS_STATE_KEY]?.let { raw -&gt;
            runCatching { json.decodeFromString&lt;List&lt;LocalPlaylist&gt;&gt;(raw) }.getOrNull()
        } ?: emptyList()
        val next = transform(current)
        prefs[DatabaseKeys.LOCAL_PLAYLISTS_STATE_KEY] = json.encodeToString(next)
    }
}
</code></pre>
<p><a href="https://github.com/team-spotube/spotube/blob/master/composeApp/src/commonMain/kotlin/org/spotube/spotube/modules/library/local/LocalPlaylistRepository.kt">View <code>LocalPlaylistRepository.kt</code> on GitHub</a></p>
<p><img src="https://spotube.org/images/blog/albums-and-artists-from-messy-tags/anim/playlists.gif" alt="Two change tickets wait on a spike. The first one enters a dashed store.edit frame, where the whole playlist document is pulled from its drawer, decoded into playlist cards, changed, encoded back into one JSON sheet and written back, before the second ticket gets its turn" /></p>
<p><em>Read, transform, encode, write: all inside one edit</em></p>
<p>Writing the whole document every time sounds wasteful, but a playlist library is a small amount of JSON. Keeping the read and the write in one <code>edit</code> means concurrent writers cannot lose each other's changes. The test <code>movingAFileUpdatesEveryPlaylistWithoutDuplicatingAliases</code> exercises the path rewrite. <code>corruptedStoreFallsBackToEmpty</code> checks the failure mode we care about most: a damaged file must never crash the library screen. When the flow reads a document it cannot decode, it emits an empty list, and the next successful edit rewrites the file.</p>
<p>Ids come from 16 random bytes, rendered as hex and prefixed with <code>local:</code>. Nothing clever, nothing that needs a server.</p>
<p>Covers for playlists take a different path. <code>reencodeLocalCoverBase64</code> runs a picked image through <code>encodeLocalCoverThumbnail</code>, which downscales it to <code>LOCAL_PLAYLIST_COVER_SIZE</code> (480 px), and returns the result <a href="https://en.wikipedia.org/wiki/Base64">base64</a>-encoded. That keeps a gallery photo from bloating the JSON document. If the picked image cannot be decoded, the cover is left unchanged. At the repository level, a <code>null</code> cover argument keeps the current cover and an empty string removes it. The edit form sends <code>null</code> when no new image was picked.</p>
<h2>What we would tell ourselves earlier</h2>
<p>Tags are a suggestion, not a contract. The grouping code is strict about what it normalizes (case, whitespace, blank tags) and deliberately does not guess beyond that: no album artist, no cover voting, no opinion on which spelling is right. Keeping the grouping pure is what makes that rule easy to test with a list of fake tracks.</p>
<p>If your library groups something wrong, the tag is usually the culprit, and the fastest way to help us is a small example of the tags involved. Open an issue on the Spotube GitHub repository with the spellings you see, and we will take it from there.</p>
<h2>References</h2>
<ul>
<li><a href="https://musicbrainz.org/doc/Style/Artist_Credits">MusicBrainz artist credits style guide</a>: how multi-artist credits are written in a large open music database.</li>
<li><a href="https://en.wikipedia.org/wiki/ID3">ID3 on Wikipedia</a>: the common tag format that holds title, artist, album and cover art in audio files.</li>
<li><a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html">Dispatchers.Default</a>: the coroutine dispatcher used for CPU-bound work.</li>
<li><a href="https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-state-flow/">StateFlow</a>: the state holder flow type behind the tracks, albums and artists lists.</li>
<li><a href="https://developer.android.com/reference/android/provider/MediaStore">MediaStore</a>: Android's shared media index.</li>
<li><a href="https://developer.android.com/guide/topics/providers/document-provider">Storage Access Framework</a>: Android document URIs, the second way a file can be addressed.</li>
<li><a href="https://developer.android.com/topic/libraries/architecture/datastore">Jetpack DataStore</a>: the Preferences DataStore used for local playlists.</li>
<li><a href="https://en.wikipedia.org/wiki/Base64">Base64 on Wikipedia</a>: the encoding used for playlist cover thumbnails.</li>
</ul>
<hr />
<p><em>Originally published on <a href="https://spotube.org/blog/albums-and-artists-from-messy-tags">spotube.org</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Why We Migrated to Compose Multiplatform?]]></title><description><![CDATA[The journey of Spotube was not a straight forward road. It was a maze. From React-Native (yes, you heard right!) to Flutter and now to Compose…]]></description><link>https://spotube.hashnode.dev/why-we-migrated-to-compose-multiplatform</link><guid isPermaLink="true">https://spotube.hashnode.dev/why-we-migrated-to-compose-multiplatform</guid><dc:creator><![CDATA[teamspotube]]></dc:creator><pubDate>Wed, 02 Dec 2026 09:57:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0f95b00494c63f5b19dd0f/fce37493-6d09-4922-b02a-a9f416943ff5.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The journey of Spotube was not a straight forward road. It was a maze. From React-Native (yes, you heard right!) to Flutter and now to Compose Multiplatform.</p>
<h2>Backstory of frameworks</h2>
<h4>NodeGUI/React-NodeGUI</h4>
<p>React-native was the primary framework Spotube used to use. We used <a href="https://react.nodegui.org/">React-NodeGUI</a> which is basically QT with <a href="https://www.npmjs.com/package/node-gyp"><code>node-gyp</code></a> bindings bonded with <a href="https://react.dev/">React</a> to create a declarative UI framework for <a href="https://nodejs.org/en">Nodejs</a>. It was not a bad idea, was more efficient than <a href="https://www.electronjs.org/">Electron.js</a>. It had only ~50MB-ish of RAM usage and ~40MB-ish of binary size, we guess.</p>
<p>But the problem was layout and the lack of base UI components. That’s when Spotube was pretty bare bones and we were not really aware of the features or stuff people wanted or knew about. We didn’t even know what scrobbling was. It was made only for our own use because Spotify’s Electron app couldn’t be run on a Core 2 Duo, 4GB RAM PC.</p>
<h4>Transition to Flutter🐦</h4>
<p>We knew about <a href="https://flutter.dev/">Flutter</a>, but didn’t have any idea how it worked. So we started learning it and at a point we realized that we could probably migrate Spotube to Flutter. So we got our hands dirty, even had to make some audio playback libraries which were basically <a href="https://dart.dev/">Dart</a> (language Flutter is written in) bindings to <a href="https://mpv.io/">MPV</a> IPC protocol. Which to this day is actually used by the <code>just_audio</code> package through <code>just_audio_mpv</code> specifically for Linux although its unmaintained. And we literally copied the bindings from mpv-js bindings which was used in the react-nodegui version. we think we know a few people who hate us for this, so we’re sorry ig lol!</p>
<p>So, we actually decided to not use mpv and relied on <code>just_audio</code> and <code>just_audio_libwinmedia</code> and it worked good. And eventually it was not working well so we had to move on from that to a player called <code>audioplayers</code> and finally, we know nobody could guess it, but it’s <a href="https://pub.dev/packages/media_kit"><code>media_kit</code></a> which again uses MPV under the hood.</p>
<h2>Why Not Flutter?</h2>
<img src="https://spotube.org/images/blog/compose-multiplatform-migration/image.webp" alt="image.png" style="display:block;margin:0 auto" />

<p>Flutter served it’s purpose. It’s a great cross-platform framework. UIs were great, performance is near native. Though the platform integrations were a bit immature but Flutter team did overcome those problems. One thing they still haven’t improved or at least haven’t met our expectations was their Desktop support. Despite being THE QUICKEST (opens faster than native desktop/mobile apps literally) desktop app framework, their desktop support is still to this day terrible. And the only reason Flutter desktop is even usable is thanks to <a href="https://github.com/lijy91">https://github.com/lijy91</a>. And later Canonical (team behind Ubuntu) also did a great job for a Flutter desktop.</p>
<h4>About that Elephant on the tree…</h4>
<img src="https://spotube.org/images/blog/compose-multiplatform-migration/image-1.webp" alt="image.png" style="display:block;margin:0 auto" />

<p>There was also a big elephant on a tree. And the elephant finally fell from the tree on April 30, 2025. When we got a cease and desist letter from that Green Music Corp (u know who). So we had to remove anything related to that corp’s product. And the main complain was actually the use of their trademarked and registered logo and product name in our website (you are on it currently). Other ones were the abuse of their developer platform and APIs.</p>
<p>So, we had to make some changes. And legally we are now not allowed to do anything regarding that product. So, as any normal people, we rewrote part of the app to make it extensible, so it is no longer tied to that corp’s product and Spotube’s users/community can build the stuff they need. So basically, Spotube lost the thing that made Spotube, Spotube. Then the plan of making it a plugin based music streaming platform crossed our discord community’s (you’re not on it? <a href="https://discord.gg/uJ94vxB6vg">JOIN OUR DISCORD NOW</a>) mind and especially our discord mod <a href="https://github.com/owenconnorz">Owen</a>.</p>
<h4>BUT! A HUGE BUT!</h4>
<p>Flutter is not extensible. It’s an embedded UI framework written in Dart. Although Dart can run on JIT/VM/Interpreter, but flutter compiles down to binary. So we tried everything. First was shipping a JS engine but the support was not there (we’ll come back to this), so we went for the greatest plugin language of all time, LUA. That also didn’t work, because we needed to make some kind of asynchronous bridge for Lua that would work with Dart’s event loop. We couldn’t, we are not cracked devs. But, somehow we found this gold <a href="https://hetu-script.github.io/">https://hetu-script.github.io/</a> which is a custom script that runs on Dart specifically, and it’s written in Dart. It’s basically what Lua is to C. Amazing performance, like 2-3% performance difference with native Dart. It’s a great project. So we went with hetu_script, though it was unmaintained for a while and had lot of bugs and practically no ecosystem at all. We had to create the standard library, http client, crypto and pretty much everything.</p>
<p>The biggest advantage of hetu_script was it’s amazing interoperability with Dart. Even async code was totally, 100% interoperable with Dart which is so great, we can’t explain how happy we were the first time we learned about this.</p>
<h4>Problems of the solution</h4>
<p>Tho hetu_script was great, it’s syntax was closer to javascript, but it lacked community support. It’s just not a good scripting language for plugin developers. It doesn’t have any LSP/autocomplete plugin, the syntax highlighting breaks every now and then. We had to pray and hope each time we built the plugin that it would work. It was not a good developer experience and we understand why it was not picked up well by the community. So recently, we realized that we had to look for alternatives.</p>
<p>We planned on using <a href="https://bellard.org/quickjs/">QuickJS</a> so we tried doing our own dart binding to QuickJS, but failed miserably as we aforementioned our lack of intelligence and not being enough cracked (we just can’t write C/C++ code, idk why). We couldn’t even get a simple hello world to print. THERE WAS STACK OVERFLOW EVERYWHERE. And, we can confirm and declare our eternal hate for <a href="https://gcc.gnu.org/">GCC</a>, <a href="https://clang.llvm.org/">Clang</a>, <a href="https://learn.microsoft.com/en-us/cpp/?view=msvc-170">MSVC</a> and all other C/C++ compilers out there and even the C/C++ languages itself. It broke us man, we gotta admit.</p>
<h4>A Side Quest…</h4>
<blockquote>
<p>We even tried rewriting the app in <a href="https://tauri.app/">Tauri</a> and <a href="https://tauri.app/develop/plugins/develop-mobile/">Tauri-mobile</a> for JavaScript (<code>eval()</code>/<code>service workers</code>) based plugin system but it was just not good enough especially on platforms that don’t use Chromium (iOS, macOS, Linux). The performance was crap, absolute garbage. UI was fine and probably the easiest thanks to Tailwind and Shadcn but music playback was inconsistent across platforms, that it made us delete the project on spot when we were testing with Linux with WebKitGTK. We gave up on Web-technologies after that.</p>
</blockquote>
<h2>Zipline, opening the curtains of the dark room</h2>
<img src="https://spotube.org/images/blog/compose-multiplatform-migration/image-2.webp" alt="image.png" style="display:block;margin:0 auto" />

<p>After failing to create simple binding to probably the simplest to bind JS engine, QuickJS, a depressed team decided to rewrite the entire app. We found <a href="https://kotlinlang.org/compose-multiplatform/">Compose-Multiplatform</a> quite amusing. And when we learned there’s a library called <a href="https://github.com/cashapp/zipline">Zipline by cashapp</a> that has Kotlin binding to QuickJS that is fully integrated with <a href="https://kotlinlang.org/multiplatform/">Kotlin Multiplatform</a> (base of Compose Multiplatform), it clicked to us to rewrite the app for good this time.</p>
<h2>Why Compose-Multiplatform?</h2>
<p>The benefits of Compose-Multiplatform just outweighs any hope we had left on Flutter and hetu_script. Here are some of them:</p>
<ul>
<li>Fully Native Android: Compose-Multiplatform uses the native APIs and everything as it’s originally based on jetpack-compose which is the official framework for building Android apps by Google. So yes, now Spotube is a native app on Android.</li>
<li>Kotlin/JS based Plugins: Zipline library is used for this plugin support. And everyone can now write Spotube plugins in Kotlin (<a href="https://kotlinlang.org/docs/js-overview.html">Kotlin/JS</a> with no browser/nodejs API support) which has much bigger community and ecosystem. We already created docs, libraries, APIs that will solve 95% of the use cases. But you’re always welcome for new APIs in the GitHub issues.</li>
<li>Better Performance: The architecture of Compose-Multiplatform and how it is written, is just better than Flutter most of the time.</li>
<li><a href="https://github.com/TeamNewPipe/NewPipeExtractor">NewPipeExtractor</a> support: NewPipeExtractor is written in Java which Kotlin is interoperable with out of the box. So we get 100% access to NewPipeExtractor’s APIs unlike the Flutter version which has to ship a dynamic library. That means a overall binary size reduction. And even iOS support for NewPipe. Yes, Spotube will now be 100% functional on iOS and same as other platforms. You still need to use AltStore/Sideloadly.</li>
<li>Native Interop: Kotlin probably has the best interop support for different platform’s language, it literally supports Swift, Obj-C, C/C++ and Java. That literally means we can use any platform’s native APIs without touching those languages.</li>
<li>Mental peace: <a href="https://kotlinlang.org/">Kotlin</a> is 1000000x times better than Dart syntactically. It’s sugar syntax, DSL, and those juicy <code>{ }</code> lambdas are so much better and time-saving and concise than Dart, is inexplicable. Kotlin makes Spotube development and maintaining a lot better. We mean the data class and not having to use <code>build_runner</code> every single time we make puny change in our serializable classes, is worth it for a full app migration.</li>
</ul>
<blockquote>
<p>We still can’t believe the Dart team implemented the compile time <code>macro</code> support only to drop it. This alone could save millions of hours of wasted time that has gone into the<code>dart run build_runner build --delete-conflicting-outputs</code> command.</p>
</blockquote>
<p>(Mind you, we don’t hate <code>build_runner</code> (it’s improving and it’s good enough), or anyone for this. Dart team is doing great work and they’re limited with people so its understandable. But dropping a feature after putting so much time on, is something we hardly find amusing)</p>
<h4>Hyping up Compose-Multiplatform</h4>
<p>In Compose Multiplatform, we also get prebuilt media playback libraries like Android’s <code>androidx.Media3</code> , iOS’s <code>AVAudioPlayer</code> and VLC support on Desktop through <a href="https://www.capricasoftware.co.uk/projects/vlcj"><code>vlcj</code></a> . So we don’t have to hunt for libraries or make our own to handle playback, everything is just there and we only need to integrate well.</p>
<p>Compose Multiplatform is also highly composable (see what we did there?). Creating custom components (it’s called ✨Composables✨ in CMP) is just a function basically unlike Flutter.</p>
<p>The state management (<code>androidx.viewmodel</code>), navigation (<code>androidx.navigation3</code>), prebuilt material components are all great and really easy to use even for a beginner. We learned the most of the basic stuff in like 2 weeks so it’s pretty easy to pick up as well.</p>
<p>Though, we do miss Flutter’s Hot Reload. But Compose Multiplatform’s limited hot restart is not that bad and does the job basically.</p>
<p>On Linux, finally the WebView is better as Compose Multiplatform uses <a href="https://en.wikipedia.org/wiki/Java_virtual_machine">JVM</a> on desktop which has Swing/AWT support. Which allows rendering WebView or any platform view (basically another app’s window) inside the Compose Multiplatform app’s window. We used <a href="https://github.com/kdroidFilter/ComposeNativeWebview">ComposeNativeWebview</a> which uses <a href="https://github.com/tauri-apps/wry">wry</a> from tauri so basically we’re using System WebView even on desktop now! It’s pretty much same as before but, on Linux it doesn’t have to be a separate window now. And it also works better on <a href="https://flatpak.org/">Flatpak</a>.</p>
<h4>Gradlezilla</h4>
<img src="https://spotube.org/images/blog/compose-multiplatform-migration/image-3.webp" alt="image.png" style="display:block;margin:0 auto" />

<p>Probably the biggest drawback to Compose Multiplatform is setting up <a href="https://gradle.org/">Gradle</a>. It’s a mess in the Kotlin/Java/Android ecosystem. Only C/C++’s <a href="https://cmake.org/">CMake</a> could make a bigger mess but ig both compete on the same level. But once we figured how it worked and the APIs of gradle, it was pretty straight forward for us to handle most of the issue. Though it took us a year to learn the quirks of gradle. Now we can finally create Compose Multiplatform libraries, YAY!</p>
<h2>A few final words</h2>
<p>The journey of Spotube was long and full of surprises. And Spotube is a dynamic project. It adapts to it’s needs and will continue to do so. But this time we hope this rewrite will solve the major problems and flaws the old Spotube had. We used Flutter for almost 4 years. It hurts to say good bye to this great framework that helped shaping the app but we need to do this so our weak af minds can continue to maintain Spotube for coming years.</p>
<p>We have to say both Thanks and Sorry to our community and users of Spotube for supporting this project for so long!! Thanks for your unrequited loved and support which powers this project and fuels us!</p>
<blockquote>
<p>And we apologize for the ads we show in this website😥. The ad revenue helps us to continue our work on Spotube and maintenance of it. Spotube doesn’t have any big sponsors or generating any profit. It relies solely on <a href="https://opencollective.com/spotube">donations</a> and ad-revenue from this website.</p>
</blockquote>
<p><strong>But the app is totally ad-free and will always be!</strong> 💖</p>
<hr />
<p><em>Originally published on</em> <a href="https://spotube.org/blog/compose-multiplatform-migration"><em>spotube.org</em></a><em>.</em></p>
]]></content:encoded></item></channel></rss>