Update HTMLMediaElement abort event description and example (#44222)#44280
Update HTMLMediaElement abort event description and example (#44222)#44280vamshikrishnaramasamy wants to merge 1 commit into
Conversation
|
Preview URLs (1 page) |
chrisdavidmills
left a comment
There was a problem hiding this comment.
@vamshikrishnaramasamy thanks for your contribution!
I tested this locally (in Chrome), and the code, as written, doesn't fire the abort event. It looks like the src replacement takes effect immediately, so it isn't seen as replacing the original src setting.
I did manage to get the event to fire with code like this:
const video = document.querySelector("video");
video.addEventListener("abort", () => {
console.log("Video loading was aborted.");
});
video.setAttribute("src", "assets/bigbuckbunny.mp4");
setTimeout(() => {
video.setAttribute("src", "");
}, 3000);By the time the timeout ran, the video had completely loaded. This leads me to two bits of feedback concerning your work:
- Test it more thoroughly, and make sure your code fires the event as advertised.
- Think about your claim of "The
abortevent is fired when the loading of a media resource is canceled before it completes". Is it more generally when it is cancelled, but not as the result of an error?
I seem to recall that is what the spec says - it should be " loading of a media resource is canceled by the user before it completes" |
|
@vamshikrishnaramasamy This issue was already taken by #44227 - you can see in the issue that they have a linked PR. That issue was started first, so IMO the other one should continue and this should be closed |
|
Right on both counts. I didn't catch that setting |
The existing example on
HTMLMediaElement: abort_eventappends a<source>element to a<video>, which does not fire theabortevent. Per @hamishwillee on #44222, abort is fired for user-intended cancellation of a media load — typically the browser's stop button, or changing/clearingsrcmid-load.Changes:
abort: start loading a video, then changesrcto a different resource. Comment notes that clearingsrcor the browser's stop button have the same effect.Closes #44222.