MediaStreamTrack

par 2 contributeurs :

Brouillon
Cette page n'est pas terminée.

Cette fonction est expérimentale
Puisque cette fonction est toujours en développement dans certains navigateurs, veuillez consulter le tableau de compatibilité pour les préfixes à utiliser selon les navigateurs.
Il convient de noter qu'une fonctionnalité expérimentale peut voir sa syntaxe ou son comportement modifié dans le futur en fonction des évolutions de la spécification.

Résumé

L'interface  MediaStream représentes le contenu d'un flux media. Un flux est composé de plusieurs pistes, vidéos ou audio.

Propriétés

MediaStreamTrack.id Lecture seule
DOMString Contenant l'identifiant unique (GUID) de la piste. Il est généré par le navigateur.
MediaStreamTrack.kind Lecture seule
DOMString défini à "audio" si la piste est une piste audio, ou à "video", s'il s'agit d'une piste vidéo. La valeur ne change pas si la piste est dissociée de la source.
MediaStreamTrack.label Lecture seule
DOMString contenant un libellé défini par l'utilisateur qui identifie la source de la piste, comme "internal microphone". La chaine peut-être laissée vide et le rester tant qu'aucune source n'est connectée.  Lorsque la piste est dissociée de la source, le libellé ne change pas.
MediaStreamTrack.enabled
Is a Boolean value with a value of true if the track is enabled, that is allowed to render the media source stream; or false if it is disabled, that is not rendering the media source stream but silence and blackness. If the track has been disconnected, this value can be changed but has no more effect.
MediaStreamTrack.readyState
Is an enumerated value that gives the status of the track. It takes one of the following values:
  • "new" which is the original state and the track has not been connected to any source yet. In that state, the MediaStreamTrack.label will be the empty string. When a source is connected, the track state becomes "live" and an started is emitted.
  • "live" which indicates that an input is connected and does its best-effort in providing real-time data. In that case, the output of data can be switched on or off using the MediaStreamTrack.enabled attribute.
  • "ended"
MediaStreamTrack.sourceId}}
Is a Boolean value with a value of true if the ended event has been fired on the object, meaning that the stream has been completely read, or false if the end of the stream ha
MediaStreamTrack.sourceType
Is a Boolean value with a value of true if the ended event has been fired on the object, meaning that the stream has been completely read, or false if the end of hte stream has

Event handlers

MediaStreamTrack.onstarted
Is a EventHandler containing the action to perform when an started event is fired on the object, that is when a new MediaStreamTrack object is added.
MediaStreamTrack.onmute
Is a EventHandler containing the action to perform when an mute event is fired on the object, that is when the streaming is terminating.
MediaStreamTrack.onunmute
Is a EventHandler containing the action to perform when an unmute event is fired on the object, that is when a  MediaStreamTrack object is removed from it.
MediaStreamTrack.onoverconstrained
Is a EventHandler containing the action to perform when an overconstrained event is fired on the object, that is when a  MediaStreamTrack object is removed from it.
MediaStreamTrack.oneended
Is a EventHandler containing the action to perform when an ended event is fired on the object, that is when a  MediaStreamTrack object is removed from it.

Methods

MediaStreamTrack.appendConstraint()
Returns the track whose id corresponds to the one given in parameters, trackid. If no parameter is given, or if no track with that id does exists, it returns null. If several tracks have the same id, it returns the first one.
MediaStreamTrack.applyConstraints()
Stores a copy of the MediaStreamTrack given as argument. If the track has already been added to the MediaStream object, nothing happens; if the track is in the finished state, that is has already reached its end, the exception INVALID_STATE_RAISE is raised.
MediaStreamTrack.constraints()
Removes the MediaStreamTrack given as argument. If the track is not part of the MediaStream object, nothing happens; if the track is in the finished state, that is has already reached its end, the exception INVALID_STATE_RAISE is raised.
MediaStreamTrack.getConstraints()
Returns a list of the MediaStreamTrack stored in the MediaStream object that have their kind attribute set to "audio". The order is not defined, and may vary from one browser to an other, but also from one call to the method to another.
MediaStreamTrack.stop()
Returns a list of the MediaStreamTrack stored in the MediaStream object that have their kind attribute set to "video". The order is not defined, and may vary from one browser to an other, but also from one call to the method to another.

Examples

Specifications

Specification Status Comment
Media Capture and Streams
La définition de 'MediaStream' dans cette spécification.
Candidate Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Oui) (Oui) Pas de support Pas de support ?
getAudioTracks() and getVideoTracks() ? 23.0 (23.0) Pas de support Pas de support ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? (Oui) Pas de support Pas de support ?
getAudioTracks() and getVideoTracks() ? 23.0 (23.0) Pas de support Pas de support ?

See also

Étiquettes et contributeurs liés au document

Contributeurs à cette page : fscholz, AbrahamT
Dernière mise à jour par : fscholz,