On Thu, Mar 21, 2013 at 4:37 AM, Mark Watson <watsonm@netflix.com> wrote:
> On Mar 20, 2013, at 8:09 AM, Kenneth Rohde Christiansen wrote:
>
> > WebKit has devicePixelRatio so you can device the device size by using
> > that.
>
> This tells me the ratio between CSS pixels and device pixels, but this is
> still meaningless for TVs, since there is no definition of CSS pixels for
> TVs (a bit of a problem generally for web browsers on TVs, but
> nevertheless…).
>
> What I need is just the device width and height in device pixels, to know
> when it is not worth delivering a high resolution version of the content.
> It's not such a big deal with HD, since there are a dwindling number of SD
> displays, but with 4K this will be an issue.
>
You can get the viewport size (window.innerWidth/innerHeight) in CSS pixels
and multiply by devicePixelRatio to get the size in device pixels.
Rob
--
Wrfhf pnyyrq gurz gbtrgure naq fnvq, “Lbh xabj gung gur ehyref bs gur
Tragvyrf ybeq vg bire gurz, naq gurve uvtu bssvpvnyf rkrepvfr nhgubevgl
bire gurz. Abg fb jvgu lbh. Vafgrnq, jubrire jnagf gb orpbzr terng nzbat
lbh zhfg or lbhe freinag, naq jubrire jnagf gb or svefg zhfg or lbhe fynir
— whfg nf gur Fba bs Zna qvq abg pbzr gb or freirq, ohg gb freir, naq gb
tvir uvf yvsr nf n enafbz sbe znal.” [Znggurj 20:25-28]