Re: Promises in 1.0

On 4/7/15 8:58 AM, Harald Alvestrand wrote:
> Den 07. april 2015 14:20, skrev IƱaki Baz Castillo:
>> However, how could the JS detect whether the underlying WebRTC stack
>> in the browser supports callbacks and/or promises?
> Just ignore the difference-hiding libraries, and call:
>
> thePromise = navigator.mediaDevices.getUserMedia()
>
> If this function exists, you have a new browser.
>
> The old callback-compatible interface is navigator.getUserMedia.

Right, test for !!navigator.mediaDevices though, so you don't reference 
undefined! Better yet, use a polyfill like this [1].

FWIW I have polyfill PRs pending for adapter.js and webrtc/samples [2].

As Harald points out, the above is gUM. RTCPeerConnection is separate 
(still working on polyfills for those).

Both promise-based gUM and promise-based RTCPeerConnection are in 
Firefox now (try [3]).

.: Jan-Ivar :.

[1] 
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#Examples
[2] https://github.com/webrtc/adapter/pull/23
[3] http://jsfiddle.net/kshmdLq5

Received on Thursday, 9 April 2015 17:25:36 UTC