Created
March 1, 2018 14:39
-
-
Save mukulmishra18/f0d2d97a430efe4e7288012a0baf65dd to your computer and use it in GitHub Desktop.
This file contains 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
.declareMethod('calculateDuration', function (data) { | |
// Create a temporary audio element and assign the data to | |
// calculate the time duration. | |
var gadget = this, | |
audioElement = document.createElement('audio'); | |
audioElement.src = URL.createObjectURL(data); | |
return RSVP.Queue() | |
.push(function () { | |
return promiseEventListener( | |
audioElement, | |
'loadedmetadata', | |
false | |
); | |
}) | |
.push(function () { | |
gadget.duration = audioElement.duration; | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment