Skip to content
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

Set accurate duration on progress bar creation #594

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/MediaPlayer/MediaPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ const MediaPlayer = ({
timeFragment = { start: 0, end: duration };
}
timeFragment.altStart = timeFragment.start;
timeFragment.duration = duration;
manifestDispatch({
canvasTargets: [timeFragment],
type: 'canvasTargets',
Expand Down
14 changes: 0 additions & 14 deletions src/components/MediaPlayer/VideoJS/VideoJSPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ function VideoJSPlayer({

const updatePlayer = (player) => {
player.duration(canvasDurationRef.current);
player.canvasDuration = canvasDurationRef.current;
player.src(options.sources);
player.poster(options.poster);
player.canvasIndex = cIndexRef.current;
Expand Down Expand Up @@ -467,11 +466,6 @@ function VideoJSPlayer({
console.log('Player loadedmetadata');

player.duration(canvasDurationRef.current);
/**
* Set property canvasDuration in the player to use in videoJSProgress component.
* This updates the property when player.src() is updates.
*/
player.canvasDuration = canvasDurationRef.current;

// Reveal player once metadata is loaded
player.removeClass('vjs-disabled');
Expand Down Expand Up @@ -550,14 +544,6 @@ function VideoJSPlayer({
player.volume(startVolume);
player.srcIndex = srcIndex;

/**
* Set property canvasDuration in the player to use in videoJSProgress component.
* Video.js' in-built duration function doesn't seem to update as fast as
* we expect to be used in videoJSProgress component.
* Setting this in the ready callback makes sure this is updated to the
* correct value before 'loadstart' event is fired in videoJSProgress component.
*/
player.canvasDuration = canvasDurationRef.current;
if (enableTitleLink) { player.canvasLink = canvasLinkRef.current; }
// Need to set this once experimentalSvgIcons option in Video.js options was enabled
player.getChild('controlBar').qualitySelector.setIcon('cog');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class VideoJSProgress extends vjsComponent {
/** Build progress bar elements from the options */
initProgressBar() {
const { targets, srcIndex } = this.options;
const { start, end } = targets[srcIndex];
const duration = this.player.canvasDuration;
const { start, end, duration } = targets[srcIndex];
let startTime = start,
endTime = end;

Expand Down