1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update components

This commit is contained in:
Luke Pulverenti 2016-03-17 01:06:37 -04:00
parent d004fd3960
commit 2fa1b14785
15 changed files with 179 additions and 86 deletions

View file

@ -67,6 +67,7 @@ class BufferController extends EventHandler {
this.mediaSource = null;
this.media = null;
this.pendingTracks = null;
this.sourceBuffer = null;
}
this.onmso = this.onmse = this.onmsc = null;
this.hls.trigger(Event.MEDIA_DETACHED);

View file

@ -25,6 +25,18 @@ class LevelController extends EventHandler {
this._manualLevel = -1;
}
startLoad() {
this.canload = true;
// speed up live playlist refresh if timer exists
if (this.timer) {
this.tick();
}
}
stopLoad() {
this.canload = false;
}
onManifestLoaded(data) {
var levels0 = [], levels = [], bitrateStart, i, bitrateSet = {}, videoCodecFound = false, audioCodecFound = false, hls = this.hls;
@ -235,7 +247,7 @@ class LevelController extends EventHandler {
tick() {
var levelId = this._level;
if (levelId !== undefined) {
if (levelId !== undefined && this.canload) {
var level = this._levels[levelId], urlId = level.urlId;
this.hls.trigger(Event.LEVEL_LOADING, {url: level.url[urlId], level: levelId, id: urlId});
}

View file

@ -11,7 +11,7 @@ import LevelHelper from '../helper/level-helper';
import {ErrorTypes, ErrorDetails} from '../errors';
const State = {
ERROR : 'ERROR',
STOPPED : 'STOPPED',
STARTING : 'STARTING',
IDLE : 'IDLE',
PAUSED : 'PAUSED',
@ -21,7 +21,8 @@ const State = {
WAITING_LEVEL : 'WAITING_LEVEL',
PARSING : 'PARSING',
PARSED : 'PARSED',
ENDED : 'ENDED'
ENDED : 'ENDED',
ERROR : 'ERROR'
};
class StreamController extends EventHandler {
@ -30,6 +31,7 @@ class StreamController extends EventHandler {
super(hls,
Event.MEDIA_ATTACHED,
Event.MEDIA_DETACHING,
Event.MANIFEST_LOADING,
Event.MANIFEST_PARSED,
Event.LEVEL_LOADED,
Event.KEY_LOADED,
@ -48,17 +50,23 @@ class StreamController extends EventHandler {
}
destroy() {
this.stop();
this.stopLoad();
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
EventHandler.prototype.destroy.call(this);
this.state = State.IDLE;
this.state = State.STOPPED;
}
startLoad() {
startLoad(startPosition=0) {
if (this.levels) {
var media = this.media, lastCurrentTime = this.lastCurrentTime;
this.stop();
this.stopLoad();
this.demuxer = new Demuxer(this.hls);
this.timer = setInterval(this.ontick, 100);
if (!this.timer) {
this.timer = setInterval(this.ontick, 100);
}
this.level = -1;
this.fragLoadError = 0;
if (media && lastCurrentTime) {
@ -69,19 +77,18 @@ class StreamController extends EventHandler {
}
this.state = State.IDLE;
} else {
this.lastCurrentTime = this.startPosition ? this.startPosition : 0;
this.lastCurrentTime = this.startPosition ? this.startPosition : startPosition;
this.state = State.STARTING;
}
this.nextLoadPosition = this.startPosition = this.lastCurrentTime;
this.tick();
} else {
logger.warn('cannot start loading as manifest not parsed yet');
this.state = State.STOPPED;
}
}
stop() {
this.bufferRange = [];
this.stalled = false;
stopLoad() {
var frag = this.fragCurrent;
if (frag) {
if (frag.loader) {
@ -90,16 +97,11 @@ class StreamController extends EventHandler {
this.fragCurrent = null;
}
this.fragPrevious = null;
logger.log('trigger BUFFER_RESET');
this.hls.trigger(Event.BUFFER_RESET);
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
if (this.demuxer) {
this.demuxer.destroy();
this.demuxer = null;
}
this.state = State.STOPPED;
}
tick() {
@ -703,7 +705,7 @@ class StreamController extends EventHandler {
}
this.media = null;
this.loadedmetadata = false;
this.stop();
this.stopLoad();
}
onMediaSeeking() {
@ -750,6 +752,14 @@ class StreamController extends EventHandler {
}
onManifestLoading() {
// reset buffer on manifest loading
logger.log('trigger BUFFER_RESET');
this.hls.trigger(Event.BUFFER_RESET);
this.bufferRange = [];
this.stalled = false;
}
onManifestParsed(data) {
var aac = false, heaac = false, codec;
data.levels.forEach(level => {
@ -1111,6 +1121,7 @@ _checkBuffer() {
if (this.stalled && playheadMoving) {
this.stalled = false;
logger.log(`playback not stuck anymore @${currentTime}`);
}
// check buffer upfront
// if less than 200ms is buffered, and media is expected to play but playhead is not moving,
@ -1121,8 +1132,8 @@ _checkBuffer() {
jumpThreshold = 0;
} else {
// playhead not moving AND media expected to play
logger.log(`playback seems stuck @${currentTime}`);
if(!this.stalled) {
logger.log(`playback seems stuck @${currentTime}`);
this.hls.trigger(Event.ERROR, {type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_STALLED_ERROR, fatal: false});
this.stalled = true;
}

View file

@ -66,9 +66,9 @@ import {ErrorTypes, ErrorDetails} from '../errors';
// multiply frequency by 2 (see table below, equivalent to substract 3)
adtsExtensionSampleingIndex = adtsSampleingIndex - 3;
} else {
// if (manifest codec is AAC) AND (frequency less than 24kHz OR nb channel is 1) OR (manifest codec not specified and mono audio)
// Chrome fails to play back with AAC LC mono when initialized with HE-AAC. This is not a problem with stereo.
if (audioCodec && audioCodec.indexOf('mp4a.40.2') !== -1 && (adtsSampleingIndex >= 6 || adtsChanelConfig === 1) ||
// if (manifest codec is AAC) AND (frequency less than 24kHz AND nb channel is 1) OR (manifest codec not specified and mono audio)
// Chrome fails to play back with low frequency AAC LC mono when initialized with HE-AAC. This is not a problem with stereo.
if (audioCodec && audioCodec.indexOf('mp4a.40.2') !== -1 && (adtsSampleingIndex >= 6 && adtsChanelConfig === 1) ||
(!audioCodec && adtsChanelConfig === 1)) {
adtsObjectType = 2;
config = new Array(2);

View file

@ -165,9 +165,16 @@ class Hls {
this.trigger(Event.MANIFEST_LOADING, {url: url});
}
startLoad() {
startLoad(startPosition=0) {
logger.log('startLoad');
this.streamController.startLoad();
this.levelController.startLoad();
this.streamController.startLoad(startPosition);
}
stopLoad() {
logger.log('stopLoad');
this.levelController.stopLoad();
this.streamController.stopLoad();
}
swapAudioCodec() {