Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replay case #60

Merged
merged 1 commit into from
Apr 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/griffith-mp4/src/mse/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export default class MSE {
return
}

this.handleReplayCase()

this.loadData(start, end).then(mdatBuffer => {
if (!mdatBuffer) {
return
Expand Down Expand Up @@ -200,7 +202,8 @@ export default class MSE {
videoInterval: {offsetInterVal = []} = [],
mp4Data: {videoSamplesLength},
} = this.mp4Probe
if (this.mediaSource.readyState === 'open') {

if (this.mediaSource.readyState !== 'closed') {
if (offsetInterVal[1] === videoSamplesLength && !this.mseUpdating) {
this.destroy()
} else if (this.shouldFetchNextSegment()) {
Expand All @@ -209,7 +212,15 @@ export default class MSE {
}
}

handleReplayCase = () => {
if (this.mediaSource.readyState === 'ended') {
this.sourceBuffers.video.appendBuffer(new Uint8Array(0))
}
}

shouldFetchNextSegment = () => {
this.handleReplayCase()

if (!this.mseUpdating && this.mp4Probe.isDraining(this.video.currentTime)) {
return true
}
Expand Down
4 changes: 2 additions & 2 deletions packages/griffith-mp4/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default class Player extends Component {
}

handlePlay = e => {
const {currentTime, buffered = []} = this.video
if (currentTime === 0 && !buffered.length) {
const {currentTime} = this.video
if (currentTime === 0) {
this.mse.seek(0)
}

Expand Down