Freeedle / Essential-Audio-Player

Essential Audio Player JS is a simple, clean and minimal JavaScript / HTML5 / CSS web audio player.
https://essential-audio-player.net
Other
41 stars 3 forks source link

Unhanded Promise Rejection #3

Closed zerosonesfun closed 6 months ago

zerosonesfun commented 3 years ago

After clicking play button the browser dev console shows this error: Unhandled Promise Rejection: AbortError: The operation was aborted.

It does not provide a line/file.

Player still works fine.

Freeedle commented 3 years ago

Finely observed. And I wish this wouldn’t have to happen. But alas, I have to cause the error even intentionally, or else the player will not work under iOS. Perhaps in a future iOS version this will become unnecessary. I will keep an eye on that. Sorry for that. Blame Apple... But be sure that this error alert can be ignored, and the player is indeed working.

For those who want to know why: It has to do with the principle that audio must be started by user interaction (which is good). By clicking the play button a cascade of functions is set off to initialize, load, buffer and finally play the audio. During this process the iOS Safari apparently loses the connection to the initial user interaction and ultimatley blocks the audio to play. The only solution that helped (so far) is to start and immediately stop the player right after the user click, before any other operation, and this returns the error alert because in that moment there is no audio file connected yet. One day there will be a version 2.0 with an entirely rebuilt architecture that will be much more elegant and avoids this problem.

zerosonesfun commented 3 years ago

Makes sense. Thank you for this amazing player! I've bundled it into a Flarum extension (forum software just in case you haven't heard of it): https://github.com/zerosonesfun/flarum-essential-audio

Freeedle commented 6 months ago

Good news: the Unhandled Promise Rejection issue is resolved! It now works without throwing errors in the newly released v2.0