mirror of
https://github.com/videojs/video.js.git
synced 2025-01-25 11:13:52 +02:00
fix: player.duration() should return NaN if duration is not known (#4443)
player.duration() currently returns 0 if the duration is not known, when it should return NaN. The problem is that if NaN is passed to player.duration() as an argument, we set the duration to 0. If player.cache_.duration was set to NaN by other means, player.duration() would still return 0. Modify the player duration() method so that it will 1.) set the cached duration to NaN if it is passed in as an argument, and 2.) return the proper value when called without an argument.
This commit is contained in:
parent
b4dc4f85b0
commit
f5cc165cad
@ -1747,10 +1747,11 @@ class Player extends Component {
|
||||
*/
|
||||
duration(seconds) {
|
||||
if (seconds === undefined) {
|
||||
return this.cache_.duration || 0;
|
||||
// return NaN if the duration is not known
|
||||
return this.cache_.duration !== undefined ? this.cache_.duration : NaN;
|
||||
}
|
||||
|
||||
seconds = parseFloat(seconds) || 0;
|
||||
seconds = parseFloat(seconds);
|
||||
|
||||
// Standardize on Inifity for signaling video is live
|
||||
if (seconds < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user