mjpeg-player: naming

This commit is contained in:
Trek H 2020-01-29 13:22:06 +10:30
parent c10a6f7bb1
commit 1243a8606e
1 changed files with 16 additions and 22 deletions

View File

@ -16,8 +16,8 @@ export default class LevelController extends EventHandler {
Event.LEVEL_LOADED); Event.LEVEL_LOADED);
this.canload = false; this.canload = false;
this.currentLevelIndex = 0; this.currentLvlIdx = 0;
this.manualLevelIndex = -1; this.manualLvlIdx = -1;
this.timer = null; this.timer = null;
chromeOrFirefox = /chrome|firefox/.test(navigator.userAgent.toLowerCase()); chromeOrFirefox = /chrome|firefox/.test(navigator.userAgent.toLowerCase());
@ -25,7 +25,7 @@ export default class LevelController extends EventHandler {
onHandlerDestroying() { onHandlerDestroying() {
this.clearTimer(); this.clearTimer();
this.manualLevelIndex = -1; this.manualLvlIdx = -1;
} }
clearTimer() { clearTimer() {
@ -79,12 +79,6 @@ export default class LevelController extends EventHandler {
videoCodecFound = videoCodecFound || !!level.videoCodec; videoCodecFound = videoCodecFound || !!level.videoCodec;
audioCodecFound = audioCodecFound || !!level.audioCodec; audioCodecFound = audioCodecFound || !!level.audioCodec;
// erase audio codec info if browser does not support mp4a.40.34.
// demuxer will autodetect codec and fallback to mpeg/audio
if (chromeOrFirefox && level.audioCodec && level.audioCodec.indexOf('mp4a.40.34') !== -1) {
level.audioCodec = undefined;
}
levelFromSet = levelSet[level.bitrate]; // FIXME: we would also have to match the resolution here levelFromSet = levelSet[level.bitrate]; // FIXME: we would also have to match the resolution here
if (!levelFromSet) { if (!levelFromSet) {
@ -147,14 +141,14 @@ export default class LevelController extends EventHandler {
} }
get level() { get level() {
return this.currentLevelIndex; return this.curLvlIdx;
} }
set level(newLevel) { set level(newLevel) {
let levels = this._levels; let levels = this._levels;
if (levels) { if (levels) {
newLevel = Math.min(newLevel, levels.length - 1); newLevel = Math.min(newLevel, levels.length - 1);
if (this.currentLevelIndex !== newLevel || !levels[newLevel].details) { if (this.curLvlIdx !== newLevel || !levels[newLevel].details) {
this.setLevelInternal(newLevel); this.setLevelInternal(newLevel);
} }
} }
@ -167,9 +161,9 @@ export default class LevelController extends EventHandler {
if (newLevel >= 0 && newLevel < levels.length) { if (newLevel >= 0 && newLevel < levels.length) {
// stopping live reloading timer if any // stopping live reloading timer if any
this.clearTimer(); this.clearTimer();
if (this.currentLevelIndex !== newLevel) { if (this.curLvlIdx !== newLevel) {
console.log(`switching to level ${newLevel}`); console.log(`switching to level ${newLevel}`);
this.currentLevelIndex = newLevel; this.curLvlIdx = newLevel;
const levelProperties = levels[newLevel]; const levelProperties = levels[newLevel];
levelProperties.level = newLevel; levelProperties.level = newLevel;
hls.trigger(Event.LEVEL_SWITCHING, levelProperties); hls.trigger(Event.LEVEL_SWITCHING, levelProperties);
@ -196,11 +190,11 @@ export default class LevelController extends EventHandler {
} }
get manualLevel() { get manualLevel() {
return this.manualLevelIndex; return this.manualLvlIdx;
} }
set manualLevel(newLevel) { set manualLevel(newLevel) {
this.manualLevelIndex = newLevel; this.manualLvlIdx = newLevel;
if (this._startLevel === undefined) { if (this._startLevel === undefined) {
this._startLevel = newLevel; this._startLevel = newLevel;
} }
@ -251,14 +245,14 @@ export default class LevelController extends EventHandler {
} }
loadLevel() { loadLevel() {
console.log('call to loadLevel, index: ' + this.currentLevelIndex + "canload: " + this.canload); console.log('call to loadLevel, index: ' + this.curLvlIdx + "canload: " + this.canload);
if (this.currentLevelIndex !== null && this.canload) { if (this.curLvlIdx !== null && this.canload) {
const levelObject = this._levels[this.currentLevelIndex]; const levelObject = this._levels[this.curLvlIdx];
if (typeof levelObject === 'object' && if (typeof levelObject === 'object' &&
levelObject.url.length > 0) { levelObject.url.length > 0) {
const level = this.currentLevelIndex; const level = this.curLvlIdx;
const id = levelObject.urlId; const id = levelObject.urlId;
const url = levelObject.url[id]; const url = levelObject.url[id];
@ -270,8 +264,8 @@ export default class LevelController extends EventHandler {
} }
get nextLoadLevel() { get nextLoadLevel() {
if (this.manualLevelIndex !== -1) { if (this.manualLvlIdx !== -1) {
return this.manualLevelIndex; return this.manualLvlIdx;
} else { } else {
return this.hls.nextAutoLevel; return this.hls.nextAutoLevel;
} }
@ -279,7 +273,7 @@ export default class LevelController extends EventHandler {
set nextLoadLevel(nextLevel) { set nextLoadLevel(nextLevel) {
this.level = nextLevel; this.level = nextLevel;
if (this.manualLevelIndex === -1) { if (this.manualLvlIdx === -1) {
this.hls.nextAutoLevel = nextLevel; this.hls.nextAutoLevel = nextLevel;
} }
} }