A music player that connects to your cloud/distributed storage.

refactor: isPlaying

+25 -11
+23 -9
src/components/engine/audio/element.js
··· 25 25 class AudioEngine extends BroadcastableDiffuseElement { 26 26 static NAME = "diffuse/engine/audio"; 27 27 28 + constructor() { 29 + super(); 30 + 31 + this.isPlaying = this.isPlaying.bind(this); 32 + this.state = this.state.bind(this); 33 + } 34 + 28 35 // SIGNALS 29 36 30 37 #items = signal(/** @type {Audio[]} */ ([])); ··· 244 251 // 🛠️ 245 252 246 253 /** 254 + * Convenience signal to track if something is, or was, playing. 255 + */ 256 + _isPlaying() { 257 + return computed(() => { 258 + const item = this.items()?.[0]; 259 + if (!item) return false; 260 + 261 + const state = this.state(item.id); 262 + if (!state) return false; 263 + 264 + return state.isPlaying() || state.hasEnded() || state.progress() === 1; 265 + }); 266 + } 267 + 268 + /** 247 269 * Get the state of a single audio item. 248 270 * 249 271 * @param {string} audioId ··· 262 284 * Convenience signal to track if something is, or was, playing. 263 285 */ 264 286 isPlaying() { 265 - return computed(() => { 266 - const item = this.items()?.[0]; 267 - if (!item) return false; 268 - 269 - const state = this.state(item.id); 270 - if (!state) return false; 271 - 272 - return state.isPlaying() || state.hasEnded() || state.progress() === 1; 273 - }); 287 + return this._isPlaying()(); 274 288 } 275 289 276 290 /**
+1 -1
src/components/orchestrator/queue-audio/element.js
··· 50 50 if (!this.queue) return; 51 51 52 52 const activeTrack = this.queue.now(); 53 - const isPlaying = untracked(this.audio.isPlaying()); 53 + const isPlaying = untracked(this.audio.isPlaying); 54 54 55 55 // Resolve URIs 56 56 const resolvedUri = activeTrack
+1 -1
src/themes/blur/artwork-controller/element.js
··· 76 76 }); 77 77 78 78 #isPlaying = computed(() => { 79 - return this.$audio.value?.isPlaying()(); 79 + return this.$audio.value?.isPlaying(); 80 80 }); 81 81 82 82 // LIFECYCLE