import { MediaStreamTrack } from "../../media/track" ; import { MediaWriter } from "./writer" ; import { WebmFactory } from "./writer/webm" ; export class MediaRecorder { writer : MediaWriter ; ext : string ; constructor ( public tracks , public path , public options = { } ) { this . ext = path . split ( "." ) . slice ( - 1 ) [ 0 ] ; this . writer = ( ( ) => { switch ( this . ext ) { case "webm" : return new WebmFactory ( path , options ) ; default : throw new Error ( ) ; } } ) ( ) ; } addTrack ( track ) { this . tracks . push ( track ) ; } start ( ) { this . writer . start ( this . tracks ) ; } async stop ( ) { await this . writer . stop ( ) ; } } export interface MediaRecorderOptions { width : number ; height : number ; }