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: failed to execute start on TimeRanges #71

Merged
merged 2 commits into from
Apr 17, 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
6 changes: 4 additions & 2 deletions packages/griffith-mp4/src/mse/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class MSE {
const time = isSeek ? this.video.currentTime : Math.floor((start + end) / 2)
const buffered = this.video.buffered

if (buffered) {
if (buffered && buffered.length > 0) {
for (let i = 0; i < buffered.length; i++) {
if (time >= buffered.start(i) && time <= buffered.end(i)) {
return true
Expand Down Expand Up @@ -213,7 +213,9 @@ export default class MSE {
const track = this.sourceBuffers[key]
const length = track.buffered.length

track.remove(track.buffered.start(0), track.buffered.end(length - 1))
if (length > 0) {
track.remove(track.buffered.start(0), track.buffered.end(length - 1))
}
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/griffith-mp4/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class Player extends Component {
const currentTime = this.video.currentTime
const buffered = this.video.buffered

if (isSafari) {
if (isSafari && buffered && buffered.length > 0) {
if (currentTime - 0.1 > buffered.start(0)) {
this.mse.seek(this.video.currentTime)
} else if (currentTime < buffered.start(0)) {
Expand Down Expand Up @@ -57,7 +57,12 @@ export default class Player extends Component {
handleVideoProgress = e => {
const buffered = this.video.buffered
const currentTime = this.video.currentTime
if (isSafari && buffered.length > 0 && currentTime < buffered.start(0)) {
if (
isSafari &&
buffered &&
buffered.length > 0 &&
currentTime < buffered.start(0)
) {
this.handleVideoSeeking()
}
this.props.onProgress(e)
Expand Down