-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Adding a method to get the ratio of video length buffered compared to bufferingGoal #3392
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
26dc16c
Merge pull request #1 from google/master
surajkumar-sk 68499bf
Merge pull request #2 from google/master
surajkumar-sk 9a2fcf3
added method for checking video efficiency
surajkumar-sk f075f84
Update player.js
surajkumar-sk 3d69e48
updated changes
surajkumar-sk 073e0c9
updated player.js
surajkumar-sk 83262a3
updated player.js
surajkumar-sk 245a3b2
updated player.js
surajkumar-sk ad964c8
updated comment in player.js
surajkumar-sk ff4979f
updated variables
surajkumar-sk 3172ce0
updated changes
surajkumar-sk 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2837,6 +2837,32 @@ shaka.Player = class extends shaka.util.FakeEventTarget { | |
return this.config_; | ||
} | ||
|
||
/** | ||
* Returns the ratio of video length buffered compared to buffering Goal | ||
* @return {number} | ||
* @export | ||
*/ | ||
getBufferFullness() { | ||
const bufferedLength_ = this.video_ ? | ||
this.video_.buffered.length : 0; | ||
const bufferedEnd_ = | ||
bufferedLength_ ? this.video_.buffered.end(bufferedLength_ - 1) : 0; | ||
const bufferingGoal_ = this.getConfiguration().streaming.bufferingGoal; | ||
const lengthToBeBuffered = this.video_ ? Math.min(this.video_.currentTime + | ||
bufferingGoal_, this.seekRange().end) : 0; | ||
|
||
if (this.video_) { | ||
surajkumar-sk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (bufferedEnd_ >= lengthToBeBuffered) { | ||
return 1; | ||
} else if (bufferedEnd_ <= this.video_.currentTime) { | ||
return 0; | ||
} else if (bufferedEnd_ < lengthToBeBuffered) { | ||
return ((bufferedEnd_ - this.video_.currentTime) / bufferingGoal_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This calculation looks correct to me now. Thanks! |
||
} | ||
} | ||
return 0; | ||
} | ||
|
||
/** | ||
* Reset configuration to default. | ||
* @export | ||
|
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.
Style-wise, we don't end local variables with underscores. That is the convention for private member variables.
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.
Updated.