W3C home > Mailing lists > Public > public-webrtc@w3.org > November 2012

Re: [ACTION-59] Introduce lookup by id structures for streams and tracks.

From: Martin Thomson <martin.thomson@gmail.com>
Date: Thu, 15 Nov 2012 13:01:46 -0800
Message-ID: <CABkgnnVQ8X_GBUohtm+0jcnVboTGHhuTcM4u47DtzUxWRepe4w@mail.gmail.com>
To: Adam Bergkvist <adam.bergkvist@ericsson.com>
Cc: "public-webrtc@w3.org" <public-webrtc@w3.org>
On 15 November 2012 02:47, Adam Bergkvist <adam.bergkvist@ericsson.com> wrote:
> I'd like to add a third:
> 3) Get the only track of a certain kind (if any) from a stream created by
> getUserMedia().
>
> The forEach() approach has gotten some support, but I think it's a bit
> clumsy doing 3) from the list of common uses.
>
> var theTrack;
> stream.audioTracks.forEach(function (track) {
>     theTrack = track;
> });

That would not be ideal; it selects the last audio track by iterating
over the whole collection.

We have better tools available:

MediaStream.prototype.getAudioTracks = function() {
    return this.getTracks().filter(function(track) {
        return track.type === 'audio';
    });
};

Whether that is provided by the browser, or needs to be polyfilled, I
don't care.  getTracks() is the key interface.

How important is it for application developers to be able to mess with
the contents of their MediaStreams anyway?
Received on Thursday, 15 November 2012 21:02:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:17:35 UTC