- From: Anant Narayanan <anant@mozilla.com>
- Date: Mon, 3 Oct 2011 12:39:30 -0700
- To: public-webrtc@w3.org
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 Monday, 3 October 2011 19:39:33 UTC