-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Play event behavior does not match video play event #898
Comments
I can confirm this is a different behavior, I'll bring this up with the team but it might be not sufficient reason to change.
This quote is not fully correct. For the The https://codesandbox.io/p/sandbox/mux-video-vs-video-events-yhd22m?file=%2Findex.html%3A41%2C48 |
@luwes The problem arises when you want to tell, that the video has actually started playing from the beginning... Is there an alternative to doing that? If we agree that the |
Hey @andrewbrennanfr it might be helpful to understand the scenario you're trying to account for. From your discussion, it sounds like you have a setup where you have autoplay set and you'd like to monitor if an error occurs when attempting to load and subsequently (auto)play the media. Is that correct? If yes, you may want to go with a less presumptuous monitoring condition, like: const errorListener = (event) => {
console.log("AN ERROR OCCURRED BEFORE PLAYBACK", event);
};
muxVideoEl.addEventListener("error", errorListener);
// Condition to stop monitoring for an error
muxVideoEl.addEventListener(
"playing",
(_event) => {
muxVideoEl.removeEventListener("error", errorListener);
},
// Only listen for the first occurrence of "playing"
{ once: true }
); This should account for errors before playback, regardless of autoplay, a user seek after loading media but before playing, etc. Let us know if that is appropriately capturing your scenario. As @luwes points out, we do end up doing some programmatic work "under the hood," including invoking the underlying |
@luwes So what I'm trying to do is, add some logging, whenever the user plays from So for example: I want to log something when:
I do not want to log something when:
The How I've "solved" it for now is a variation of: let isLoading = true
const handlePlay = () => {
if (isLoading) { // don't continue if still loading
return
}
// log something based on `currentTime === 0`
}
const handleMetaDataLoaded = () => {
isLoading = false
handlePlay() // resume the play event
} This way I'm sure the video has loaded successfully before playing. But it's a bit of a workaround, rather than a real fix. |
Is there an existing issue for this?
Which Mux Elements/Packages does this apply to? Select all that apply
mux-video
Which browsers are you using?
Chrome
Which operating systems are you using?
macOS
Description
In your docs, it's mentioned that the Mux player emits all of events available on the HTML5 video element & I would expect the same behaviors between both.
I've experienced 2 cases where there is a misalignment in behavior - both very similar.
The order of events emitted from the player is not the same - which is particularly problematic in the case of an error loading the video.
<mux-video />
=> https://stackblitz.com/edit/vitejs-vite-e37ply?file=src%2FApp.vue&terminal=dev<video />
=> https://stackblitz.com/edit/vitejs-vite-mmoxmh?file=src%2FApp.vue&terminal=devReduced test case
https://stackblitz.com/edit/vitejs-vite-e37ply?file=src%2FApp.vue&terminal=dev
Steps to reproduce
✅ Case 1 - A video successfully loads
Order of events for
<video />
elementloadedmetadata
event is emitted firstplay
event is emittedOrder of events for
<mux-video />
elementplay
event is emitted firstloadedmetadata
event is emitted❌ Case 2 - A video does not successfully load
Order of events for
<video />
elementerror
event is emittedOrder of events for
<mux-video />
elementplay
event is emitted (even though the video isn't played)error
event is emittedCurrent Behavior
The
play
event is always emitted immediately whenautoplay
istrue
- even if the video is errored.The
play
event is emitted, before theloadedmetadata
- which should not be the case.Expected Behavior
play
can & should only be emitted after the video successfully loads - both whenautoplay
istrue
& also if the user was to try & play the video before it loaded successfully.Errors
No response
What version of the package are you using?
v0.17.5
The text was updated successfully, but these errors were encountered: