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-01-25 15:28:29 -05:00
parent 53c2a5fe3c
commit 24ad560e5a
16 changed files with 223 additions and 126 deletions

View file

@ -21,7 +21,8 @@ const State = {
PARSING : 5,
PARSED : 6,
APPENDING : 7,
BUFFER_FLUSHING : 8
BUFFER_FLUSHING : 8,
ENDED : 9
};
class MSEMediaController extends EventHandler {
@ -86,6 +87,7 @@ class MSEMediaController extends EventHandler {
this.mp4segments = [];
this.flushRange = [];
this.bufferRange = [];
this.stalled = false;
var frag = this.fragCurrent;
if (frag) {
if (frag.loader) {
@ -264,13 +266,23 @@ class MSEMediaController extends EventHandler {
// have we reached end of VOD playlist ?
if (!levelDetails.live) {
var mediaSource = this.mediaSource;
if (mediaSource && mediaSource.readyState === 'open') {
// ensure sourceBuffer are not in updating states
var sb = this.sourceBuffer;
if (!((sb.audio && sb.audio.updating) || (sb.video && sb.video.updating))) {
logger.log('all media data available, signal endOfStream() to MediaSource');
//Notify the media element that it now has all of the media data
mediaSource.endOfStream();
if (mediaSource) {
switch(mediaSource.readyState) {
case 'open':
var sb = this.sourceBuffer;
if (!((sb.audio && sb.audio.updating) || (sb.video && sb.video.updating))) {
logger.log('all media data available, signal endOfStream() to MediaSource and stop loading fragment');
//Notify the media element that it now has all of the media data
mediaSource.endOfStream();
this.state = State.ENDED;
}
break;
case 'ended':
logger.log('all media data available and mediaSource ended, stop loading fragment');
this.state = State.ENDED;
break;
default:
break;
}
}
}
@ -456,6 +468,8 @@ class MSEMediaController extends EventHandler {
each time sourceBuffer updateend() callback will be triggered
*/
break;
case State.ENDED:
break;
default:
break;
}
@ -864,6 +878,9 @@ class MSEMediaController extends EventHandler {
// switch to IDLE state to load new fragment
this.state = State.IDLE;
}
} else if (this.state === State.ENDED) {
// switch to IDLE state to check for potential new fragment
this.state = State.IDLE;
}
if (this.media) {
this.lastCurrentTime = this.media.currentTime;
@ -1188,17 +1205,27 @@ _checkBuffer() {
var currentTime = media.currentTime,
bufferInfo = this.bufferInfo(currentTime,0),
isPlaying = !(media.paused || media.ended || media.seeking || readyState < 3),
jumpThreshold = 0.2;
jumpThreshold = 0.2,
playheadMoving = currentTime > media.playbackRate*this.lastCurrentTime;
if (this.stalled && playheadMoving) {
this.stalled = false;
}
// check buffer upfront
// if less than 200ms is buffered, and media is playing but playhead is not moving,
// and we have a new buffer range available upfront, let's seek to that one
if(bufferInfo.len <= jumpThreshold) {
if(currentTime > media.playbackRate*this.lastCurrentTime || !isPlaying) {
if(playheadMoving || !isPlaying) {
// playhead moving or media not playing
jumpThreshold = 0;
} else {
// playhead not moving AND media playing
logger.log('playback seems stuck');
if(!this.stalled) {
this.hls.trigger(Event.ERROR, {type: ErrorTypes.MEDIA_ERROR, details: ErrorDetails.BUFFER_STALLED_ERROR, fatal: false});
this.stalled = true;
}
}
// if we are below threshold, try to jump if next buffer range is close
if(bufferInfo.len <= jumpThreshold) {