media query not triggering on source tag when page is resized
Is it expected behavior here for source to not change when screen is resized and use the source which matched when the screen size when page loaded?
I noticed that my browser isn't fetching the
1080 & 2000
request when i resize. Before i start debugging i'd like to do a sanity check and ask here if it's expected behavior or not65 Replies
you have a minimum width, but not a maximum width
the other sizes won't load because the minimum 640px will always fulfill it
oh. i was in the tailwind mindset. thanks for pointing it out.
you're welcome
it's something easy to miss out
I'm gonna try this
that probably won't do what you need in some aspects
you should have a top and bottom limit as well
depending on the needs
by the way, on the question you have 640px, and on that last message you have 600px
no? ones the first one is
false
at 600px will it not default to the desktop version?that leaves 40px where there's no source that matches
yea I changed it completly . I'm still testing stuff. what i showed you is what i have on my code so you don't have to worry about me showing you different code then what's actually there.
oh, well, which sizes do you have?
just one
but it's not defaulting to the desktop version when i resize to 1080. ill try adding a media to it now.
that is interesting 🤔
i would expect it to do it, but maybe it doesn't because the media query is missing
still doesn't work. hmm
try limiting from 600 to 1080
but obviously, over 1080 shouldn't work
yes.
not sure what you mean? like setting a range?
no, a media query
oh okay.
I tried this
and i set my page to 200px and reloaded. network tab downloads the mobile version. Then i resized to 2000px but network tab did not download the desktop version.
typo
1 sec missed the px there
1080 is not a valid value
that was probably why it didn't work
still didn't work. let me quickly record a video. i have to be doing something very stupid here
lets see
here you go
the cropped version is the mobile version and the hero-video is the desktop version.
i think i know what it is
go ahead
can you check the
currentSource
property of the video player?from where?
in tehh dev tools?
oh wait i get it.
yes
and it's
currentSrc
instead
straight from the dev tools
that's the html, not a property of the element
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentSrc
okay. brb
that property should change
it does not
hmm.
honestly, i have no idea
a bug in html?
no
just weird shit and i don't see why it shouldn't work
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source#using_the_media_attribute_with_video
this is what you tried before
look at this. it's just an index.html i created and even this doesn't work. no react, vite, tailwind. nothing fancy
that won't work because the video is 1000x1000
that's relevent?
if im not mistaken, yes
removing it doesn't work either
i removed the source tag while sending it to you
can you try this exact code on your machine?
it seems to only work on refresh
yep. same here.
i used this instead
lol is there a a big sos button that calls kevin
i don't recommend it
i do remember something like this before, somewhere
i know he helped someone before with something sorta related (image instead of video)
but it was a long time ago
any keywords that you remember from it?
not really, it was more than 2 months ago
probably was during the summer
i can't go digging if i don't know anyting about it. :/
i know, but it's unrealistic to remember a random question from a while ago
https://discord.com/channels/436251713830125568/1222964697557368962/1222997676581453838
this was the only closest thingn i could find.
wasn't that one, but that should help
I don't know officially, but from experience, I believe those media tags are only read on load and not on resize.
that's what thee experiments show so far
someone shared this in the other server
https://scottjehl.com/posts/responsive-video/
We're Bringing Responsive Video Back! | Scott Jehl, Web Designer/De...
Let's revisit responsive HTML video delivery and talk about when we can use it again and how close we are to cross-browser compatibility
Well that explains it.
that shows the exact same behaviour
once the large one is loaded, it stays there
i'll just set a one time self destructing event listener to load the desktop version of the video if the page is resized
something like
if ya'll got any other ideas let me know
yeah, implement something that does this for you
or use an already existing project that does all for you
i couldn't find any public projects that do this. I'll just have to implement it on my own.
you can easily implement this
yea