Last active
January 30, 2019 06:50
-
-
Save tai2/d456299d66c69f96f180b929d4832219 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function getVideoDuration(src: string): Promise<number> { | |
return new Promise((resolve, reject) => { | |
const video = document.createElement('video') | |
video.src = src | |
video.addEventListener('loadedmetadata', () => { | |
resolve(video.duration) | |
}) | |
video.addEventListener('error', error => { | |
reject(error) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment