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

VideoJS does not update the duration display when the duration is NaN or 0. #5347

Closed
fketchakeu opened this Issue Jul 26, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@fketchakeu
Copy link
Contributor

fketchakeu commented Jul 26, 2018

Description

VideoJS does not update the duration display when the duration is NaN or 0.
Here is a reduced test case (Case A).
The issue also occurs when changing the player source and preload = 'none'.
Here is a reduced test case (Case B)

Steps to reproduce Case A

Go to Case A .
After the video has loaded, note the duration display has been updated.
click on setDuration(0) or setDuration(NaN).

Results In Case A

Expected

When clicking on setDuration(10) or setDuration(30) or setDuration(0.0001), the duration display UI updated.
Thus when clicking on setDuration(0) or setDuration(NaN) we expect the duration display to update to "0:00”,
or perhaps something like '-:-', in the case of NaN.

Actual

Clicking on setDuration(0) or setDuration(NaN) does not update the duration display.

Steps to reproduce Case B

Go to Case B
Click on the "swap SRC" button and observe the duration display.

Results In Case B

Expected

The duration display should reset to 0:00 or something like '-:-'.

Actual

The duration display doesn't update when the source is changed.

Additional Information

With plain html5 video, changing the source does indeed reset the duration,
in harmony with Spec (see step 10.4 of media element load algorithm).
e.g. Html5 equivalent of Case B
When the source is changed, in Firefox and Chrome, the player UI is updated to reflect the duration change.

versions

videojs

This is occurring in the latest version as of this post (v7.1.0)

@gkatsev

This comment has been minimized.

Copy link
Member

gkatsev commented Jul 26, 2018

I do see the duration change in case b when the new source is loaded. I see it change from 21s to 30s.

As for case A, what's the usecase for setting a duration of 0 or NaN? Infinity does work and it puts the player into a live state as that's what a duration of infinity represents. I'd except you to only call player.duration() if you have a known/better duration than what the media returns.

fketchakeu added a commit to fketchakeu/video.js that referenced this issue Jul 26, 2018

fix: duration reset, and allow duration NaN or 0 for duration display
This allows the duration NaN or 0 to update the duration display.
This also resets the duration display when a new media item is loaded with `preload` set to 'none'.

Fixes videojs#5347
@fketchakeu

This comment has been minimized.

Copy link
Contributor Author

fketchakeu commented Jul 26, 2018

I removed the reference to Infinity, since it doesn't apply here.

In case B, the duration display updates only after the video starts playing, not when the source is changed. It cannot have changed from 21s to 30s prior to playing since preload is 'none'.

A use case for case A is actually case B. When the source is changed, duration should change to NaN according to W3C specs (https://www.w3.org/TR/2011/WD-html5-20110113/video.html#media-element-load-algorithm). Pull request #5348 addresses this.

Another minor use case for case A is purely for esthetic purpose. Suppose I change the media source but do not want it loaded right away (preload = 'none'), the duration should be NaN. That would normally (with #5348 fix applied) change the duration display to -:-. For better or for worse, one may prefer a 0:00 rendering, and therefore manually resets to 0 by calling setDuration(0).

@stale

This comment has been minimized.

Copy link

stale bot commented Sep 28, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 28, 2018

@gkatsev gkatsev removed the wontfix label Sep 28, 2018

gkatsev added a commit that referenced this issue Nov 14, 2018

fix: duration reset and allow duration NaN or 0 for duration display (#…
…5348)

This allows the duration NaN or 0 to update the duration display.
This also resets the duration display when a new media item is loaded with `preload` set to 'none'.

Fixes #5347
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment