Skip to content

Commit

Permalink
fix: default subtitle not working
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed May 9, 2024
1 parent 060aa83 commit d024d6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultOptions = {
muted: false,
loop: false,
volume: 1,
preload: '',
preload: 'metadata',
playbackRate: 1,
playsinline: true,
lang: 'auto',
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/ui",
"version": "1.3.1",
"version": "1.3.2-beta.0",
"description": "ui plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/src/components/Subtitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ export class Subtitle {
this.processDefault(this.options.source)

this.createContainer()
this.fetchSubtitle()
this.loadSetting()

if (this.currentSubtitle) {
if (this.player.isSourceChanging || isNaN(this.player.duration) || this.player.duration < 1) {
this.player.once('loadedmetadata', () => this.fetchSubtitle())
} else {
this.fetchSubtitle()
}
}

this.player.on(['destroy', 'videosourcechange'], this.destroy.bind(this))
this.player.on('videoqualitychang', () => {
if (this.isShow) this.hide()
Expand Down

0 comments on commit d024d6e

Please sign in to comment.