-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tech 2.0 additional fixes #2166
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
815518e
Remove the old options default arg in Tech
eXon 7a08b45
this.tech.emitTapEvents(); should be handled by the tech
eXon 8040884
De-dupe the bufferedPercent code in both Tech and Player
eXon 39a6d7f
Have the player generate the tech ID
eXon 152717e
Added autoplay/preload/loop/muted to tech option
eXon 1766e2c
Remove the watch for native timeupdates
eXon e3c0285
Fixed the JSDoc for bufferedPercent
eXon 5d19240
Removed the unit test for native timeupdate
eXon 6f455f4
Added cute whitespaces
eXon aa998c9
Merge remote-tracking branch 'upstream/master'
eXon 956d77a
buffer should always return a TimeRange
eXon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { createTimeRange } from './time-ranges.js'; | ||
|
||
/** | ||
* Compute how much your video has been buffered | ||
* @param {Object} Buffered object | ||
* @param {Number} Total duration | ||
* @return {Number} Percent buffered of the total duration | ||
* @private | ||
*/ | ||
export function bufferedPercent(buffered, duration) { | ||
var bufferedDuration = 0, | ||
start, end; | ||
|
||
if (!duration) { | ||
return 0; | ||
} | ||
|
||
if (!buffered || !buffered.length) { | ||
buffered = createTimeRange(0, 0); | ||
} | ||
|
||
for (let i = 0; i < buffered.length; i++){ | ||
start = buffered.start(i); | ||
end = buffered.end(i); | ||
|
||
// buffered end can be bigger than duration by a very small fraction | ||
if (end > duration) { | ||
end = duration; | ||
} | ||
|
||
bufferedDuration += end - start; | ||
} | ||
|
||
return bufferedDuration / duration; | ||
} |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. For #2033 I want to try to move away from using options like this and instead use the player properties (e.g.
this.autoplay()
), but there's still more work to do to make that even possible. Not something for this PR but just wanted to call it out as something that may change in the near future.