addSourceBuffer(type) {
    let buffer;
    let parsedType = parseContentType(type);

    // Create a VirtualSourceBuffer to transmux MPEG-2 transport
    // stream segments into fragmented MP4s
    if ((/^(video|audio)\/mp2t$/i).test(parsedType.type)) {
      let codecs = [];

      if (parsedType.parameters && parsedType.parameters.codecs) {
        codecs = parsedType.parameters.codecs.split(',');
        codecs = translateLegacyCodecs(codecs);
        codecs = codecs.filter((codec) => {
          return (isAudioCodec(codec) || isVideoCodec(codec));
        });
      }

      if (codecs.length === 0) {
        codecs = ['avc1.4d400d', 'mp4a.40.2'];
      }

      buffer = new VirtualSourceBuffer(this, codecs);

      if (this.sourceBuffers.length !== 0) {
        // If another VirtualSourceBuffer already exists, then we are creating a
        // SourceBuffer for an alternate audio track and therefore we know that
        // the source has both an audio and video track.
        // That means we should trigger the manual creation of the real
        // SourceBuffers instead of waiting for the transmuxer to return data
        this.sourceBuffers[0].createRealSourceBuffers_();
        buffer.createRealSourceBuffers_();

        // Automatically disable the audio on the first source buffer if
        // a second source buffer is ever created
        this.sourceBuffers[0].audioDisabled_ = true;
      }
    } else {
      // delegate to the native implementation
      buffer = this.nativeMediaSource_.addSourceBuffer(type);
    }

    this.sourceBuffers.push(buffer);
    return buffer;
  }
/**
   * Add a source buffer to the media source.
   *
   * @link https://developer.mozilla.org/en-US/docs/Web/API/MediaSource/addSourceBuffer
   * @param {String} type the content-type of the content
   * @return {Object} the created source buffer
   */
Add a source buffer to the media source.
Add a source buffer to the media source .
addSourceBuffer(type) {
    let buffer;
    let parsedType = parseContentType(type);
    if ((/^(video|audio)\/mp2t$/i).test(parsedType.type)) {
      let codecs = [];
      if (parsedType.parameters && parsedType.parameters.codecs) {
        codecs = parsedType.parameters.codecs.split(',');
        codecs = translateLegacyCodecs(codecs);
        codecs = codecs.filter((codec) => {
          return (isAudioCodec(codec) || isVideoCodec(codec));
        });
      }
      if (codecs.length === 0) {
        codecs = ['avc1.4d400d', 'mp4a.40.2'];
      }
      buffer = new VirtualSourceBuffer(this, codecs);
      if (this.sourceBuffers.length !== 0) {
        this.sourceBuffers[0].createRealSourceBuffers_();
        buffer.createRealSourceBuffers_();
        this.sourceBuffers[0].audioDisabled_ = true;
      }
    } else {
      buffer = this.nativeMediaSource_.addSourceBuffer(type);
    }
    this.sourceBuffers.push(buffer);
    return buffer;
  }
addSourceBuffer ( type ) { let buffer ; let parsedType = parseContentType ( type ) ; if ( ( / ^(video|audio)\/mp2t$ / i ) . test ( parsedType . type ) ) { let codecs = [ ] ; if ( parsedType . parameters && parsedType . parameters . codecs ) { codecs = parsedType . parameters . codecs . split ( ',' ) ; codecs = translateLegacyCodecs ( codecs ) ; codecs = codecs . filter ( ( codec ) => { return ( isAudioCodec ( codec ) || isVideoCodec ( codec ) ) ; } ) ; } if ( codecs . length === 0 ) { codecs = [ 'avc1.4d400d' , 'mp4a.40.2' ] ; } buffer = new VirtualSourceBuffer ( this , codecs ) ; if ( this . sourceBuffers . length !== 0 ) { this . sourceBuffers [ 0 ] . createRealSourceBuffers_ ( ) ; buffer . createRealSourceBuffers_ ( ) ; this . sourceBuffers [ 0 ] . audioDisabled_ = true ; } } else { buffer = this . nativeMediaSource_ . addSourceBuffer ( type ) ; } this . sourceBuffers . push ( buffer ) ; return buffer ; }
Add a source buffer to the media source.
Add a source buffer to the media source .
// Create a VirtualSourceBuffer to transmux MPEG-2 transport // stream segments into fragmented MP4s // If another VirtualSourceBuffer already exists, then we are creating a // SourceBuffer for an alternate audio track and therefore we know that // the source has both an audio and video track. // That means we should trigger the manual creation of the real // SourceBuffers instead of waiting for the transmuxer to return data // Automatically disable the audio on the first source buffer if // a second source buffer is ever created // delegate to the native implementation