- From: Martin Thomson <martin.thomson@gmail.com>
- Date: Thu, 15 Nov 2012 13:01:46 -0800
- 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