f37c0f91d4
refs https://github.com/TryGhost/Team/issues/1230 - extracts audio duration and mimeType metadata for uploaded file
16 lines
425 B
JavaScript
16 lines
425 B
JavaScript
export default function extractAudioMetadata(file) {
|
|
return new Promise((resolve) => {
|
|
let audio = new Audio();
|
|
let duration;
|
|
const mimeType = file.type;
|
|
audio.onloadedmetadata = function () {
|
|
duration = audio.duration;
|
|
resolve({
|
|
duration,
|
|
mimeType
|
|
});
|
|
};
|
|
audio.src = URL.createObjectURL(file);
|
|
});
|
|
}
|