Skip to content

Commit

Permalink
fix(xgplayer): Let destroy api's behavior tend to be synchronized(Res…
Browse files Browse the repository at this point in the history
…olves bytedance#689, resolves bytedance#466)
  • Loading branch information
gemxx committed Jul 22, 2022
1 parent b21e409 commit d96becf
Show file tree
Hide file tree
Showing 2 changed files with 9,647 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/xgplayer/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ class Player extends Proxy {
allOff(this)
}

if (!this.paused) {
this.pause()
this.once('pause', destroyFunc)
} else {
destroyFunc.call(this)
}
// destroy immediately
// Don't use the paused property detection, it doesn't use MediaElement.paused,
// so it's not accurate enough. Destroy after waiting for pause event, this
// changes the synchronous behavior of destroy api
destroyFunc.call(this)

super.destroy()
}

Expand Down
Loading

0 comments on commit d96becf

Please sign in to comment.