-
Notifications
You must be signed in to change notification settings - Fork 45
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
mux-video script tag doesn't consistently fire native video events #60
Comments
thanks for reporting this bug. I have reproduced this issue on my end. it seems like you said, it only starts working once the script has been loaded and then the event is attached or in other words attaching video events only work after the custom element has been upgraded. it's because the video events are still dispatched on the internal video element itself only and we don't dispatch on the |
also note that in plain HTML the workaround is as easy as putting the script tag without (async / defer) before the mux-video tag and adding events after will always work as expected. see https://codesandbox.io/s/mux-video-events-ku2rud or bundling (import) the mux-video script before rendering the mux-video tag and it should work as expected. |
Yeah, you're correct but we want to lazy-load the script - load on-demand
Yes that works, and it was made by me and referenced in the issue decription > SvelteKit REPL |
Checklist
npm install @mux-elements/[element_name]
oryarn @mux-elements/[element_name]
.Which Mux Elements/Packages has a bug?
Which browser(s) are you using?
Which operating system(s) are you using?
macOS
How are you using Mux Elements?
Describe the bug
Native video events e.g.
loadedmetadata
are inconsistently fired across different browsers.Steps To Reproduce
in a svelte project:
mux-video
script tag to the root html e.g.app.html
/vid
route and the following snippet~/vid
with your devtool openloadedmetadata
never fires. You can get the metadata on component mount thoughloadedmetadata
fires quite right butvideoWidth = 0
andvideoHeight = 0
. Attempting to read the values on component mount returns0
for all 3 variables.chrome
.I should mention that the event fires right with the
npm package
.I'm providing 2 links to code examples so that you can run it across many browsers as possible - for example safari is not compatible with stackblitz but works with svelte REPL. On svelte REPL, I provided 2 files
Bug.svelte
andWorkaround.svelte
.Link to code example:
The current behavior
Native video events don't fire as expected when using the script tag - focusing only on the
loadedmetadata
event for this issue. The workaround is waiting for the script to getloaded
before rendering themux-video
tag. This means that one would need to load the script using javascript or any method that allows for access to theloaded
eventThe expected behavior
All native video events should fire usually and as expected without needing to hook to
loaded
event.The text was updated successfully, but these errors were encountered: