Skip to content

Commit

Permalink
fix修改new Promise没有reject问题 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
longgegege authored Oct 16, 2024
1 parent 4e0c2e8 commit 1ddb48e
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions harmony/rn_video/src/main/ets/view/PlayPlayer.ets
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,28 @@ export struct PlayPlayer {
async preparePlayer(): Promise<string | media.AVFileDescriptor> {
this.closeFsRawFd()
return new Promise(async(resolve, reject) => {
let src:string | media.AVFileDescriptor = '';
if (this.srcParam.startsWith('http')) {
this.type = CommonConstants.TYPE_INTERNET
src = this.srcParam
this.previousSrc = undefined
} else if(this.srcParam.startsWith('asset')) {
const fileUrl = this.srcParam.split('//')[1];
let fileDescriptor = await getContext(this).resourceManager.getRawFd(`assets/${fileUrl}`);
this.previousSrc = `assets/${fileUrl}`
src = fileDescriptor;
} else if (this.srcParam.startsWith('file:')){
this.previousSrc = fs.openSync(this.srcParam, fs.OpenMode.READ_ONLY)
src = `fd://${this.previousSrc.fd}`;
} else {
this.previousSrc = undefined
Logger.debug(TAG, `local, finalsrc: ${(src)}`);
try{
let src:string | media.AVFileDescriptor = '';
if (this.srcParam.startsWith('http')) {
this.type = CommonConstants.TYPE_INTERNET
src = this.srcParam
this.previousSrc = undefined
} else if(this.srcParam.startsWith('asset')) {
const fileUrl = this.srcParam.split('//')[1];
let fileDescriptor = await getContext(this).resourceManager.getRawFd(`assets/${fileUrl}`);
this.previousSrc = `assets/${fileUrl}`
src = fileDescriptor;
} else if (this.srcParam.startsWith('file:')){
this.previousSrc = fs.openSync(this.srcParam, fs.OpenMode.READ_ONLY)
src = `fd://${this.previousSrc.fd}`;
} else {
this.previousSrc = undefined
Logger.debug(TAG, `local, finalsrc: ${(src)}`);
}
resolve(src)
} catch(error){
reject(error)
}
resolve(src)
})
}

Expand All @@ -161,6 +165,8 @@ export struct PlayPlayer {
if (this.playVideoModel) {
this.playVideoModel.switchVideo(src);
}
}).catch((err:BusinessError)=>{
Logger.debug(TAG, `onSrcChanged, preparePlayer error message:${err.message},error code:${err.code}`);
})
}

Expand Down Expand Up @@ -219,6 +225,8 @@ export struct PlayPlayer {
if (this.playVideoModel) {
this.playVideoModel.firstPlay(this.index, src, this.surfaceID);
}
}).catch((err:BusinessError)=>{
Logger.debug(TAG, `onSrcChanged, preparePlayer error message:${err.message},error code:${err.code}`);
})

})
Expand Down

0 comments on commit 1ddb48e

Please sign in to comment.