Skip to content

Commit

Permalink
v2.5.03 - Set default to auto mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
oddengine committed Apr 3, 2023
1 parent cb66d2b commit cf28b2a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/player/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ui.setup(player, {
lowlatency: true, // ll-dash, ll-hls, ll-flv/fmp4 (auto reduce latency due to cumulative ack of tcp)
maxBufferLength: 1.5, // sec.
maxRetries: 0, // maximum number of retries while some types of error occurs. -1 means always
mode: 'live', // live, vod
mode: 'auto', // auto, live, vod
module: 'FLV', // SRC, FLV, FMP4, DASH*, HLS*, RTC
objectfit: 'contain', // fill, contain, cover, none, scale-down
retrying: 0, // ms. retrying interval
Expand Down
2 changes: 1 addition & 1 deletion src/odd.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
odd = function () {
return {
version: '2.5.02',
version: '2.5.03',
};
};

2 changes: 1 addition & 1 deletion src/player/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
maxBufferLength: 1.5, // sec.
maxPlaybackLength: 10, // sec. for live mode only, set NaN to disable
maxRetries: 0, // maximum number of retries while some types of error occurs. -1 means always
mode: 'live', // live, vod
mode: 'auto', // auto, live, vod
module: '', // SRC, FLV, FMP4, DASH*, HLS*, RTC
muted: false,
objectfit: 'contain', // fill, contain, cover, none, scale-down
Expand Down
19 changes: 12 additions & 7 deletions src/player/player.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,30 @@
};

_this.duration = function (duration) {
if (utils.typeOf(duration) === 'number') {
if (duration !== _duration && !(isNaN(_duration) && isNaN(duration))) {
_logger.log('Model duration change: ' + duration);
if (utils.typeOf(duration) === 'number' && duration !== _duration && !(isNaN(_duration) && isNaN(duration))) {
_logger.log('Model duration change: ' + duration);
if (_usermode === 'auto') {
// NaN -> Infinity: live
// NaN -> Number: vod
// Infinity -> NaN: live
// Infinity -> Number: live
// Number -> NaN: user config
// Number -> Infinity: live (should not happen)
// Number -> Number: live (Mac Safari)
var mode;
if (isNaN(_duration) && duration !== Infinity) {
_this.config.mode = 'vod';
mode = 'vod';
} else if (_duration !== Infinity && isNaN(duration)) {
_this.config.mode = _usermode;
mode = _usermode;
} else {
_this.config.mode = 'live';
mode = 'live';
}
if (_this.config.mode !== mode) {
_this.config.mode = mode;
_logger.log('Model mode change: ' + _this.config.mode);
}
_duration = duration;
}
_duration = duration;
}
return _duration;
};
Expand Down

0 comments on commit cf28b2a

Please sign in to comment.