HTML5Video - Fix invalid getDuration method response #50
+16
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
TL;DR: Fixes clappr/clappr#1910.
Currently, the
HTML5Video
playback calls the_ready
method even if the HTMLMediaElement is not ready yet. This PR moves the_ready
call to inside the_onLoadedMetadata
method, which will be called after the HTMLMediaElement loadedmetadata event occurs.With this change, the
ready
event is only called after the HTMLMediaElement metadata is available.Changes
html5_video.js
:_ready
call insiderender
method;_ready
call inside_onLoadedMetadata
method;if
statements insiderender
method;template
for the to of class declaration;html5_video.test.js
:_onLoadedMetadata
method;How to test
ready
state has updated on any Clappr scope.events: { onReady: function() { alert(`player.getDuration returns: ${this.getDuration()}`) } }
on Clappr initial setup.A picture/video tells a thousand words
iMac with Firefox:
Before this PR:
After this PR:
iOS with Safari:
Before this PR:
After this PR: