UNPKG

@fakes/media-devices

Version:

A interactive fake implementation of MediaDevices interface in the browser for testing

64 lines 3.27 kB
import { Context } from './context'; import { MediaStreamTrackFake } from './MediaStreamTrackFake'; export declare type MediaStreamEventListener = (this: MediaStream, ev: MediaStreamTrackEvent) => any; export declare const mediaStreamId: () => string; export declare class MediaStreamFake extends EventTarget implements MediaStream { private readonly _context; private readonly _id; private readonly mediaTracks; constructor(_context: Context, _id: string, mediaTracks: Array<MediaStreamTrackFake>); /** * A Boolean value that returns true if the MediaStream is active, or false otherwise. * A stream is considered active if at least one of its MediaStreamTracks is not in the MediaStreamTrack.ended state. * Once every track has ended, the stream's active property becomes false. */ get active(): boolean; /** * A {@DOMString} containing 36 characters denoting a universally unique identifier (UUID) for the object. */ get id(): string; get onaddtrack(): MediaStreamEventListener | null; set onaddtrack(_listener: MediaStreamEventListener | null); get onremovetrack(): MediaStreamEventListener | null; set onremovetrack(_listener: MediaStreamEventListener | null); /** * Stores a copy of the MediaStreamTrack given as argument. * If the track has already been added to the MediaStream object, nothing happens. * @param track */ addTrack(track: MediaStreamTrack): void; /** * Returns a clone of the MediaStream object. * The clone will, however, have a unique value for {@link MediaStreamFake.id id}. */ clone(): MediaStream; /** * Returns a list of the {@link MediaStreamTrackFake} objects stored in the {@link MediaStreamFake} object that have their kind attribute set to audio. * The order is not defined, and may not only vary from one browser to another, but also from one call to another. */ getAudioTracks(): MediaStreamTrackFake[]; /** * 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 exist, it returns null. * If several tracks have the same ID, it returns the first one. * @param trackId */ getTrackById(trackId: string): MediaStreamTrackFake | null; /** * Returns a list of all {@link MediaStreamTrackFake} objects stored in the MediaStream object, regardless of the value of the kind attribute. * The order is not defined, and may not only vary from one browser to another, but also from one call to another. */ getTracks(): MediaStreamTrackFake[]; /** * Returns a list of the {@link MediaStreamTrackFake} objects stored in the MediaStream object that have their kind attribute set to "video". * The order is not defined, and may not only vary from one browser to another, but also from one call to another. */ getVideoTracks(): MediaStreamTrackFake[]; /** * Removes the {@link MediaStreamTrackFake} given as argument. * If the track is not part of the MediaStream object, nothing happens. * @param toRemove */ removeTrack(toRemove: MediaStreamTrack): void; } //# sourceMappingURL=MediaStreamFake.d.ts.map