What is blob in the <video src=blob:url>?

后端 未结 3 581
耶瑟儿~
耶瑟儿~ 2020-12-24 07:00

Can anyone explain what the blob: indicates in the URL in this video tag?

3条回答
  •  春和景丽
    2020-12-24 07:01

    That is a youtube video with shaka player which plays DASH content without browser plugins using Media Source Extensions.

    The blob url is generated by createObjectURL. for example:

    var video = document.querySelector('video');
    
    var assetURL = 'frag_bunny.mp4';
    // Need to be specific for Blink regarding codecs
    // ./mp4info frag_bunny.mp4 | grep Codec
    var mimeCodec = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"';
    
    if ('MediaSource' in window && MediaSource.isTypeSupported(mimeCodec)) {
      var mediaSource = new MediaSource;
      //console.log(mediaSource.readyState); // closed
      video.src = URL.createObjectURL(mediaSource);
      mediaSource.addEventListener('sourceopen', sourceOpen);
    } else {
      console.error('Unsupported MIME type or codec: ', mimeCodec);
    }
    

提交回复
热议问题