Skip to content

Commit

Permalink
refactor: 💡 (xgplayer) preProcessUrl API 对外使用
Browse files Browse the repository at this point in the history
  • Loading branch information
gemxx committed Aug 26, 2024
1 parent ddc6aa9 commit f80f089
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/xgplayer/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class Player extends MediaProxy {
if (!url) {
url = this.url || this.config.url
}
const _furl = this._preProcessUrl(url)
const _furl = this.preProcessUrl(url)
const ret = this._startInit(_furl.url)
return ret
})
Expand All @@ -983,7 +983,7 @@ class Player extends MediaProxy {
if (Util.typeOf(url) === 'Object') {
_src = url.url
}
_src = this._preProcessUrl(_src).url
_src = this.preProcessUrl(_src).url
const curTime = this.currentTime
this.__startTime = curTime
const isPaused = this.paused && !this.isError
Expand Down Expand Up @@ -1394,7 +1394,7 @@ class Player extends MediaProxy {
runHooks(this, 'retry', () => {
const cur = this.currentTime
const { url } = this.config
const _srcRet = !Util.isMSE(this.media) ? this._preProcessUrl(url) : { url }
const _srcRet = !Util.isMSE(this.media) ? this.preProcessUrl(url) : { url }
this.src = _srcRet.url
!this.config.isLive && (this.currentTime = cur)
this.once(Events.CANPLAY, () => {
Expand Down Expand Up @@ -2292,8 +2292,9 @@ class Player extends MediaProxy {
* @param { IUrl } url
* @param { {[propName: string]: any} } [ext]
* @returns { url: IUrl, [propName: string]: any }
* @public
*/
_preProcessUrl (url, ext) {
preProcessUrl (url, ext) {
const { preProcessUrl, preProcessUrlOptions } = this.config
const processUrlOptions = Object.assign({}, preProcessUrlOptions, ext)
return !Util.isBlob(url) && typeof preProcessUrl === 'function' ? preProcessUrl(url, processUrlOptions) : { url }
Expand Down

0 comments on commit f80f089

Please sign in to comment.