init commit
This commit is contained in:
21
remotion/node_modules/@remotion/media-utils/dist/audio-buffer/audio-url-helpers.js
generated
vendored
Normal file
21
remotion/node_modules/@remotion/media-utils/dist/audio-buffer/audio-url-helpers.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.audioBufferToDataUrl = void 0;
|
||||
const audio_buffer_to_wav_1 = require("./audio-buffer-to-wav");
|
||||
/*
|
||||
* @description Takes an AudioBuffer instance and converts it to a Base 64 Data URL so it can be passed to an <Html5Audio /> tag.
|
||||
* @see [Documentation](https://remotion.dev/docs/audio-buffer-to-data-url)
|
||||
*/
|
||||
const audioBufferToDataUrl = (buffer) => {
|
||||
const wavAsArrayBuffer = (0, audio_buffer_to_wav_1.audioBufferToWav)(buffer, {
|
||||
float32: true,
|
||||
});
|
||||
let binary = '';
|
||||
const bytes = new Uint8Array(wavAsArrayBuffer);
|
||||
const len = bytes.byteLength;
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return 'data:audio/wav;base64,' + window.btoa(binary);
|
||||
};
|
||||
exports.audioBufferToDataUrl = audioBufferToDataUrl;
|
||||
Reference in New Issue
Block a user