js获取视频时长

通过js获取视频/音频时长

const url = window.URL.createObjectURL(file)
const audioElement = new Audio(url)
audioElement.addEventListener('loadedmetadata', () => {
    const duration = audioElement.duration
})
posted @ 2024-03-05 11:32  梦羽微澜  阅读(329)  评论(0编辑  收藏  举报