Take an audio sample like on https://www.mediawiki.org/wiki/Extension:TimedMediaHandler/VideoJS_Player
Every once in a while, when you click the audio player to open the dialog, you get the audio sample playing TWICE. This seems related to the play/pause logic we do on the original element to ensure autoplay interaction permissions.
- the first play is registered (native playback of mp3 or vorbis source)
- the pause is also executed
- but it seems the pause is sometimes not actually pausing inside Safari
I did some investigation and the pause is inside the promise now (to fix the error with the abort we were sometimes seeing when pausing during the play phase). It seems to me that this is a bug in Safari, and when I do setTimeout around the pause action, it works much more reliably, because it gets put on the next execution cycle.
Be careful with debugging, long pauses invalidate the play action, console logging is more accurate for analysing this problem. For videos it seems we never even get around to playing at all, as the load phase simply takes too long and/or because we don't have native playback support for these elements.