Skip to content

Commit

Permalink
feat(core): add changeQuality method
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Nov 5, 2022
1 parent 447f204 commit e833843
Show file tree
Hide file tree
Showing 8 changed files with 3,746 additions and 1,400 deletions.
4 changes: 2 additions & 2 deletions examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"@oplayer/hls": "workspace:*",
"@oplayer/react": "workspace:*",
"@oplayer/ui": "workspace:*",
"@types/react": "^18.0.24",
"@types/react": "^18.0.25",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"sass": "^1.55.0"
"sass": "^1.56.0"
}
}
4 changes: 2 additions & 2 deletions examples/standalone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@oplayer/dash": "workspace:*",
"@oplayer/hls": "workspace:*",
"@oplayer/ui": "workspace:*",
"hls.js": "^1.2.4",
"lit": "^2.4.0"
"hls.js": "^1.2.5",
"lit": "^2.4.1"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
"test": "echo 1"
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/plugin-proposal-object-rest-spread": "^7.19.4",
"@babel/core": "^7.20.2",
"@babel/plugin-proposal-object-rest-spread": "^7.20.2",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-destructuring": "^7.20.0",
"@babel/plugin-transform-destructuring": "^7.20.2",
"@babel/plugin-transform-parameters": "^7.20.1",
"@babel/plugin-transform-spread": "^7.19.0",
"@babel/plugin-transform-template-literals": "^7.18.9",
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export const VIDEO_EVENTS = [

export const PLAYER_EVENTS = ['contextmenu', 'fullscreenchange', 'fullscreenerror'] as const

export const OH_EVENTS = ['loadedplugin', 'videosourcechange', 'destroy'] as const
export const OH_EVENTS = [
'loadedplugin',
'videoqualitychange',
'videosourcechange',
'destroy'
] as const

export const EVENTS = [...VIDEO_EVENTS, ...PLAYER_EVENTS, ...OH_EVENTS] as const
11 changes: 10 additions & 1 deletion packages/core/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,19 @@ export class Player {
}
}

async changeSource(source: Source) {
_resetStatus() {
this._playPromise = undefined
this.hasError = false
this.isCustomLoader = false
}

async changeQuality(src: string) {
this.emit('videoqualitychange', src)
await this.load({ src })
}

async changeSource(source: Source) {
this._resetStatus()
this.$video.poster = source.poster || ''
this.emit('videosourcechange', source)
await this.load(source)
Expand Down
2 changes: 1 addition & 1 deletion packages/hls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
},
"devDependencies": {
"@oplayer/core": "workspace:*",
"hls.js": "^1.2.4"
"hls.js": "^1.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"devDependencies": {
"@oplayer/core": "workspace:*",
"@types/react": "^18.0.24",
"@types/react": "^18.0.25",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
Expand Down
Loading

1 comment on commit e833843

@vercel
Copy link

@vercel vercel bot commented on e833843 Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

oplayer – ./

oplayer.vercel.app
oplayer-git-main-shiyiya.vercel.app
oplayer-shiyiya.vercel.app

Please sign in to comment.