代码之家  ›  专栏  ›  技术社区  ›  Nhu Trinh

从blob url读取数据[重复]

  •  0
  • Nhu Trinh  · 技术社区  · 8 年前

    我已经用xhr预装了一个mp4视频,并将其保存到blob url中

    xhr.responseType = 'blob'
    // xhr send and get response
    var url = URL.createObjectURL(xhr.response);
    player.src(url);
    // It's worked, it's playable and seekable.
    //url = blob url string
    

    blob: http://domain/9d0d26c3-b7ba-4302-9186-d23c6ad53bd5

    1 回复  |  直到 8 年前
        1
  •  1
  •   Benjamin J.    8 年前

    我做了一些研究,因为我也对这个问题感兴趣,我认为唯一的可能性是对XHR请求进行处理。我想这里已经讨论过了: How to get a file or blob from an object URL?

    如果你有一个blob,你可以用 FileReader 到a ArrayBuffer . 但也许以下方法也可行:

    xhr.responseType = 'arraybuffer';
    
    推荐文章