-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional tech 2.0 improvements from #2126
closes #2166 closes #2126 this.tech.emitTapEvents(); should be handled by the tech De-dupe the bufferedPercent code in both Tech and Player Have the player generate the tech ID Added autoplay/preload/loop/muted to tech option Remove the watch for native timeupdates Fixed the JSDoc for bufferedPercent Removed the unit test for native timeupdate Added cute whitespaces buffer should always return a TimeRange
- Loading branch information
Showing
7 changed files
with
59 additions
and
91 deletions.
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
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