MediaStreamTrackGenerator: MediaStreamTrackGenerator() constructor
Insertable Streams for MediaStreamTrack API
Insertable Streams for MediaStreamTrack API
The **`MediaStreamTrackGenerator()`** constructor creates a new MediaStreamTrackGenerator object which consumes a stream of media frames and exposes a MediaStreamTrack.
## Syntax
```js-nolint
new MediaStreamTrackGenerator(options)
```
### Parameters
- `options`
- : An object containing the property `kind`, which is one of the following strings:
- `"audio"`
- : Specifies that the stream accepts AudioTrack objects.
- `"video"`
- : Specifies that the stream accepts VideoTrack objects.
### Exceptions
- TypeError
- : Thrown if `init.kind` is not `"video"` or `"audio"`.
## Examples
In the following example a new video `MediaStreamTrackGenerator` is created.
```js
const trackGenerator = new MediaStreamTrackGenerator({ kind: "video" });
```
## Specifications
## Browser compatibility
## See also
- [Insertable streams for MediaStreamTrack](https://developer.chrome.com/docs/capabilities/web-apis/mediastreamtrack-insertable-media-processing)
Cite this
"MediaStreamTrackGenerator: MediaStreamTrackGenerator() constructor". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrackGenerator/MediaStreamTrackGenerator JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy