Ghost/ghost/admin/lib/koenig-editor/addon/utils/extract-audio-metadata.js
Rishabh f37c0f91d4 Added metadata extraction for audio file in card
refs https://github.com/TryGhost/Team/issues/1230

- extracts audio duration and mimeType metadata for uploaded file
2021-12-09 13:12:45 +05:30

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);
});
}