Re: [mediaqueries] Media Source Extensions and device capabilities

On Tue, Nov 18, 2014 at 12:20 PM, Mark Watson <watsonm@netflix.com> wrote:
> On Tue, Nov 18, 2014 at 9:45 AM, Tab Atkins Jr. <jackalmage@gmail.com>
> wrote:
>> This might be something we need to solve in HTML, by adopting
>> something analogous to srcset.  Or, if we're okay with letting CSS
>> override <video> source selection, we can solve it with something
>> parallel to image-set(), specialized for videos.
>
> I think it's clear that for the <source> / @srcset case, then giving the UA
> the information is needs to make the choice is the right solution.
>
> For our use-case, though, we are using the Media Source Extension so it is
> fundamentally the script that decides which stream is downloaded. So the
> script needs the same information the UA would use in a declarative setting.

Ah, if scripting is involved, this is easier.  window.devicePixelRatio
gives you the screen density on all webkit/blink/ff browsers (dunno
about IE).  You can then just measure the element normally using
existing JS APIs, and use those two pieces of information to figure
out what source to load.

Discounting any connection speed-based decision-making browsers might
do, this is the same information that the browser uses to decide
srcset stuff.

~TJ

Received on Tuesday, 18 November 2014 20:44:23 UTC