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

Configure Feed

Select the types of activity you want to include in your feed.

Improve poor connection handling

+12 -4
+12 -4
src/Javascript/audio-engine.js
··· 232 232 let audio 233 233 234 234 const bind = fn => event => { 235 + console.log(event.type, event) 235 236 const is = isActiveAudioElement(orchestrion, event.target) 236 237 if (is) fn.call(orchestrion, event) 237 238 } ··· 262 263 audio.addEventListener("seeked", bind(audioLoaded)) 263 264 audio.addEventListener("timeupdate", bind(audioTimeUpdateEvent)) 264 265 265 - // `stalled` event doesn't work properly on Safari 266 - if (!IS_SAFARI) audio.addEventListener("stalled", bind(audioStalledEvent)) 266 + // `stalled` event doesn't work properly (mostly on Safari and mobile devices) 267 + // if (!IS_SAFARI) audio.addEventListener("stalled", bind(audioStalledEvent)) 267 268 268 269 audio.load() 269 270 audioElementsContainer.appendChild(audio) ··· 308 309 // Audio events 309 310 // ------------ 310 311 312 + let showedNoNetworkError = false 311 313 let timesStalled = 1 312 314 313 315 ··· 331 333 if (event.target.currentTime && event.target.currentTime > 0) { 332 334 showNetworkErrorNotification.call(this) 333 335 audioStalledEvent.call(this, event) 334 - } else { 336 + } else if (navigator.onLine) { 335 337 showUnsupportedSrcErrorNotification.call(this) 336 338 clearTimeout(this.loadingTimeoutId) 337 339 this.app.ports.setAudioIsLoading.send(false) 340 + } else { 341 + showNetworkErrorNotification.call(this) 342 + audioStalledEvent.call(this, event) 338 343 } 339 344 break 340 345 default: ··· 344 349 345 350 346 351 function showNetworkErrorNotification() { 352 + if (showedNoNetworkError) return 353 + showedNoNetworkError = true 347 354 this.app.ports.showErrorNotification.send( 348 355 navigator.onLine 349 356 ? "I can't play this track because of a network error. I'll try to reconnect." ··· 455 462 456 463 457 464 function audioCanPlayEvent(event) { 465 + showedNoNetworkError = false 458 466 setDurationIfNecessary.call(this, event.target) 459 467 } 460 468 ··· 543 551 node.load() 544 552 node.currentTime = time 545 553 546 - if (timesStalled > 5 && navigator.onLine) { 554 + if (timesStalled > 5 && !showedNoNetworkError && navigator.onLine) { 547 555 this.app.ports.showStickyErrorNotification.send( 548 556 "You loaded too many tracks too quickly, " + 549 557 "which the browser can't handle. " +