A music player that connects to your cloud/distributed storage.
at v4 76 lines 2.4 kB view raw
1import * as Output from "~/common/output.js"; 2import { html, render as litRender } from "lit-html"; 3import { effect } from "~/common/signal.js"; 4import foundation from "~/common/foundation.js"; 5 6const main = /** @type {HTMLElement} */ (document.querySelector("main")); 7main.classList.add("has-loaded"); 8 9const orchestrator = await foundation.orchestrator.processTracks({ 10 disableWhenReady: true, 11}); 12 13const placeholder = document.querySelector("#placeholder"); 14if (!placeholder) throw new Error("No #placeholder element"); 15 16/** 17 * Wait until tracks are loaded and only then start processing. 18 */ 19async function process() { 20 const output = await foundation.orchestrator.output(); 21 22 await Output.data(output.tracks); 23 await orchestrator.process(); 24} 25 26effect(() => { 27 const isProcessing = orchestrator.isProcessing(); 28 const { processed, total } = orchestrator.progress(); 29 const percentage = total > 0 ? Math.round((processed / total) * 100) : 0; 30 31 litRender( 32 isProcessing 33 ? html` 34 <fieldset> 35 <legend>Processing tracks</legend> 36 <div class="with-icon with-icon--large"> 37 <img src="images/icons/windows_98/gears-0.png" width="24" /> 38 <span> 39 ${total === 0 40 ? "Going through all the inputs and gathering the tracks ..." 41 : `Making sure each track has metadata & statistics (${processed} / ${total}) ...`} 42 </span> 43 </div> 44 <div 45 class="progress-indicator" 46 style="margin-top: var(--grouped-element-spacing);" 47 > 48 <div 49 class="progress-indicator-bar" 50 style="width: ${percentage}%" 51 > 52 </div> 53 </div> 54 </fieldset> 55 ` 56 : html` 57 <fieldset> 58 <div class="with-icon with-icon--large"> 59 <img src="images/icons/windows_98/gears-0.png" width="24" /> 60 <div> 61 <p> 62 Go through all the inputs you've added and get the last audio files and 63 their metadata. 64 </p> 65 <p> 66 <button @click="${process}"> 67 Process sources 68 </button> 69 </p> 70 </div> 71 </div> 72 </fieldset> 73 `, 74 /** @type {HTMLElement} */ (placeholder), 75 ); 76});