I am playing with getUserMedia
. Code is super simple:
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var video = $('#video')[0];
navigator.getUserMedia({
audio: false,
video: true
}, function(stream){
video.src = (window.URL) ? window.URL.createObjectURL(stream) : stream;
video.play();
window.stream = stream;
}, function(error){ });
When I am accessing stream
I always see that id
and label
is always the same.
ended: false
id: "WgpeMZaOLc7LslcVmfumid0gaLLdNg0aWifl"
label: "WgpeMZaOLc7LslcVmfumid0gaLLdNg0aWifl"
onaddtrack: null
onended: null
onremovetrack: null
What is the reason to have them equal?
Assuming you are talking about the MediaStreamTrack object - the specs defines:
id of type DOMString, readonly
... Unless a MediaStreamTrack object is created as a part a of special purpose algorithm that specifies how the track id must be initialized, the user agent MUST generate a globally unique identifier string and initialize the object's id attribute to that string ...
label of type DOMString, readonly
User agents MAY label audio and video sources (e.g., "Internal microphone" or "External USB Webcam"). The MediaStreamTrack.label attribute MUST return the label of the object's corresponding track, if any. If the corresponding track has or had no label, the attribute MUST instead return the empty string.
So it appears the browser manufacturer (Google or Mozilla ...) may provide a label for a source but that is only a may whereas the id is a must. Hence depending on the browser you are using you can get a label that could be the same as the id - or no label - or a different one.