W3C home > Mailing lists > Public > public-webrtc@w3.org > April 2015

Re: Promises in 1.0

From: Jan-Ivar Bruaroey <jib@mozilla.com>
Date: Thu, 09 Apr 2015 13:25:05 -0400
Message-ID: <5526B5F1.8010008@mozilla.com>
To: public-webrtc@w3.org
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

This archive was generated by hypermail 2.3.1 : Monday, 23 October 2017 15:19:43 UTC