The Context
I'm using the HTML video element to play HLS+Fairplay streams (VOD and live) in Safari.
My application is a Netflix-like. You can watch a video, stop, and watch another one.
Concretly, the <video>
tag is created upon each play and destroyed when the player exits.
The Problem
Sometimes, after exiting the player, launching a new video causes a MEDIA_ERR_DECODE
error without anymore explation.
I can trace in my code that the Fairplay certificate and the CKC
have been correctly retrieved and that the media session has been created and updated (with the CKC
).
In fact, when I log everything, I see the exact same logs as when it works. Except the final MEDIA_ERR_DECODE
error.
When I get this error, if I immediately retry to play, the same error happens, but if I wait about 5~10 seconds, it successfully plays. It's like some resource is waiting to be garbage-collected.
What I tried
I tried playing non-DRMed videos and it works perfectly: I could play, stop, play, etc. without any issue.
So my guess is something is happening at the EME level.
I've browse the whole Internet (twice) and couldn't come up with a clear explanation.
Most of the hints I found couldn't explain my issue (e.g. bad DRM-encryption, but how could it work the first time?) or solve it (e.g. videoElement.src = ""
).
I'm throwing a bottle into the sea, here...
I feel like Indiana Jones, excavating this quite old question. ⛏️
But for those stumbling here, after looking for their symptoms online, please rejoice, because it's now fixed.
I don't know if it was fixed by a release of Safari, or Shaka Player, or both, but it has been fixed at some point.
You're welcome.