Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
squarebracket committed Aug 16, 2017
1 parent 1ed612b commit b9fe08d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
15 changes: 0 additions & 15 deletions src/flash-media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@ export default class FlashMediaSource extends videojs.EventTarget {
this.sourceBuffers = [];
this.readyState = 'closed';

this.onPlayerSeeked_ = () => {
this.sourceBuffers.forEach((sourceBuffer) => {
if (sourceBuffer.transmuxer_) {
sourceBuffer.transmuxer_.seeked();
}
});
};

this.on(['sourceopen', 'webkitsourceopen'], (event) => {
// find the swf where we will push media data
this.swfObj = document.getElementById(event.swfId);
this.player_ = videojs(this.swfObj.parentNode);
this.tech_ = this.swfObj.tech;
this.readyState = 'open';

this.player_.on('seeked', this.onPlayerSeeked_);
this.tech_.on('seeking', () => {
let i = this.sourceBuffers.length;

Expand All @@ -58,12 +49,6 @@ export default class FlashMediaSource extends videojs.EventTarget {
}
});

this.on('sourceclose', () => {
if (this.player_.el_) {
this.player_.off('seeked', this.onPlayerSeeked_);
}
});

}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/flash-source-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export default class FlashSourceBuffer extends videojs.EventTarget {
// On a seek we remove all text track data since flash has no concept
// of a buffered-range and everything else is reset on seek
this.mediaSource_.player_.on('seeked', () => {
this.resetCaptionsIfAppropriate();
removeCuesFromTrack(0, Infinity, this.metadataTrack_);
removeCuesFromTrack(0, Infinity, this.inbandTextTrack_);
});
Expand All @@ -187,6 +188,15 @@ export default class FlashSourceBuffer extends videojs.EventTarget {
});
}

resetCaptionsIfAppropriate() {
let range = this.player_.buffered();
let current = this.player_.currentTime();

if (range.length && current >= range.end(0) || current <= range.start(0)) {
this.transmuxer_.postMessage({action: 'resetCaptions'});
}
}

/**
* Append bytes to the sourcebuffers buffer, in this case we
* have to append it to swf object.
Expand Down
4 changes: 2 additions & 2 deletions src/flash-transmuxer-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ class MessageHandlers {
this.transmuxer.flush();
}

seeked() {
this.transmuxer.seeked();
resetCaptions() {
this.transmuxer.resetCaptions();
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/html-media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ export default class HtmlMediaSource extends videojs.EventTarget {
});
};

this.onPlayerSeeked_ = () => {
this.onPlayerSeeking_ = (event) => {
this.sourceBuffers.forEach((sourceBuffer) => {
if (sourceBuffer.transmuxer_) {
sourceBuffer.transmuxer_.seeked();
let range = this.player_.buffered();
let current = this.player_.currentTime();

if (current >= range.end(0) || current <= range.start(0)) {
sourceBuffer.transmuxer_.postMessage({action: 'resetCaptions'});
}
}
});
};
Expand Down Expand Up @@ -195,7 +200,7 @@ export default class HtmlMediaSource extends videojs.EventTarget {
}

this.player_.on('mediachange', this.onPlayerMediachange_);
this.player_.on('seeked', this.onPlayerSeeked_);
this.player_.on('seeking', this.onPlayerSeeking_);
});

this.on('sourceended', (event) => {
Expand Down Expand Up @@ -239,7 +244,7 @@ export default class HtmlMediaSource extends videojs.EventTarget {
// event handlers left to unbind anyway
if (this.player_.el_) {
this.player_.off('mediachange', this.onPlayerMediachange_);
this.player_.off('seeked', this.onPlayerSeeked_);
this.player_.off('seeking', this.onPlayerSeeking_);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/transmuxer-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class MessageHandlers {
this.transmuxer.flush();
}

seeked() {
this.transmuxer.seeked();
resetCaptions() {
this.transmuxer.resetCaptions();
}
}

Expand Down

0 comments on commit b9fe08d

Please sign in to comment.