Re: CHANGE: Use a JS Object as an argument to getUserMedia

Anant,

This looks reasonable to me if we could avoid any error-prone string 
manipulation by introducing a JS object mechanism.

Regards,

Soo-Hyun Choi
Next Generation S/W R&D Group
Samsung Electronics
E: sh9.choi@samsung.com
M: +82-(0)10-4929-4349


On 10/04/2011 04:39 AM, Anant Narayanan wrote:
> What
> --
> I'd like to propose that we use a JS Object instead of a string as the *only* argument to getUserMedia().
>
> Why
> --
> We're just now beginning with the implementation of the specification in Firefox and we'd rather not write a new string parser :) Parsing strings can be error prone, whereas JavaScript objects offer the same extensibility as strings (and can be stringified into JSON if required). Additionally, coming up with a new string format is extra work and will end up  very close to a structured object model anyway.
>
> In order to avoid developers from providing empty objects in case they want default behavior, it is also necessary to eliminate any other arguments to getUserMedia. This change  will also align getUserMedia to behave closer to other web APIs, where changes to state are notified either via event listeners or callbacks that have been explicitly assigned.
>
> How
> --
> It is proposed that getUserMedia takes only a single argument, a JavaScript object. To begin with, only two properties will be specified to be interpreted by the User-Agent:
>
> {
>    audio: true,
>    video: true
> }
>
> Both audio and video default to true, thus this call:
>
> var stream = navigator.media.getUserMedia();
>
> will return a MediaStream object that records both video and audio. Since getUserMedia() only takes 1 argument, the developer has to attach an event listener or callback:
>
> stream.onReadyStateChange = function() {} // Like XHR
>
> or
>
> stream.addEventListener("<event-name>", function() {}); // Event listener
>
>
> Would love to hear what everyone thinks.
>
> Regards,
> -Anant
>
>
>

Received on Wednesday, 5 October 2011 07:42:34 UTC