Skip to content

Commit

Permalink
fix: Cannot read property appendBuffer of undefined (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyuhen authored Mar 28, 2019
1 parent 85de203 commit 9415b63
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/griffith-mp4/src/mse/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export default class MSE {
}

handleSourceOpen = () => {
this.mediaSource.removeEventListener('sourceopen', this.handleSourceOpen)

const mime = 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
this.sourceBuffer = this.mediaSource.addSourceBuffer(mime)
this.sourceBuffer.addEventListener('updateend', () => {
Expand Down Expand Up @@ -79,7 +77,10 @@ export default class MSE {
FMP4.ftyp(),
FMP4.moov(this.mp4Probe.mp4Data)
)
this.appendBuffer(rawData)

this.mediaSource.addEventListener('sourceopen', () => {
this.appendBuffer(rawData)
})
})
}

Expand Down Expand Up @@ -156,7 +157,7 @@ export default class MSE {

if (this.mediaSource.readyState === 'open') {
if (offsetInterVal[1] === videoSamplesLength && !this.mseUpdating) {
this.mediaSource.endOfStream()
this.destroy()
} else if (this.shouldFetchNextSegment()) {
this.seek()
}
Expand Down

0 comments on commit 9415b63

Please sign in to comment.