How to convert the src of an audio file into a blob object?

for example, an audio tag with a src inside does not want to be exposed, so it needs to be converted into a blob object, how to do it?

there will be errors when I read the methods on the Internet before, and most of them are pictures.

Jun.24,2022

https://stackoverflow.com/que...
focuses on responseType


ah ~ omnipotent jquery

function url2Blob(url) {
  return new Promise(resolve => {
    $.ajax({
      url,
      cache: false,
      xhr: () => {
        // Seems like the only way to get access to the xhr object
        var xhr = new XMLHttpRequest();
        xhr.responseType = 'blob';
        return xhr;
      },
      success: data => {
        resolve(data);
      }
    });
  });
}
Menu