video elements fire 'error' event even when successfully assigning to video.src
aoberoi opened this issue · 4 comments
Can we find a way to intercept and swallow the 'error' event that the
repro:
videoElement.addEventListener('error', function(event) {
if (event.target.error.code === window.MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED) {
console.error(':(');
}
});
videoElement.addEventListneer('loadedmetadata' function() {
console.log('success!');
});
videoElement.src = URL.createObjectURL(stream);
The output will be:
:(
success!
I only expect:
success!
I don't see any way to prevent that "error" event. If the user sets a event listener for the "error" event in a <video>
element there is little the library/plugin can do to avoid it. In fact, the video element may be later used for rendering a remote video via a HTTP URL, so I prefer not to generate conflict with the element normal behavior.
Said that, it should be documented so I will do it on next days and leave this issue open until done.
Could it be possible to attach the addEventListener for on 'error' when we capture the src attribute change, and then on the event handler remove it and prevent event propagation?
It's being coded right now.
Version 1.3.1 published with this improvement.