Skip to content

Commit

Permalink
fix getDuration() return value when using MediaElement (#941)
Browse files Browse the repository at this point in the history
* fix getDuration() return value for MediaElement 

change getDuration function in mediaelement.js to return the correct duration length same as WebAudio.

from
        var duration = this.media.duration; // incorrect duration value returned
        console.log preview:
        https://cloud.githubusercontent.com/assets/5193884/22399178/6d26c1fe-e565-11e6-9b13-e6107641666a.png
to
        var duration = this.buffer.duration; // correct duration value returned same as WebAudio
        console.log preview:
        https://cloud.githubusercontent.com/assets/5193884/22393549/7b130096-e4d6-11e6-83ff-4ebb78b9e42f.png

* Update mediaelement.js
  • Loading branch information
entonbiba authored and katspaugh committed Feb 2, 2017
1 parent cf6e35b commit 385578b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mediaelement.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ WaveSurfer.util.extend(WaveSurfer.MediaElement, {
},

getDuration: function () {
var duration = this.media.duration;
var duration = (this.buffer || this.media).duration;
if (duration >= Infinity) { // streaming audio
duration = this.media.seekable.end(0);
}
Expand Down

0 comments on commit 385578b

Please sign in to comment.