fix(录音): 补松手瞬间空 getaudiourl 回投(对齐 Android reset()双回投)
原工程 webviewActivity/NewwebviewActivity 正常发送=upload()后紧跟reset(),
reset()立刻回投 getaudiourl{audiourl:"",time:0},上传完成再回投真实URL。
我们漏了松手那次空回投,H5状态机未复位致录完不播放。改为任何结束都先空回投,
send 再补真实URL;上传失败不再重复空回投(已发过)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
1bea5a3598
commit
7ae58e90ca
@@ -374,20 +374,22 @@ export class AudioProvider implements CapabilityProvider {
|
||||
const r: RecordResult | undefined = p as RecordResult | undefined;
|
||||
const action: string = r !== undefined ? r.action : 'cancel';
|
||||
const timeSec: number = r !== undefined ? r.timeSec : 0;
|
||||
// 对齐 Android reset():任何结束(发送/取消/太短)松手瞬间都先立刻回投一次空 getaudiourl,
|
||||
// H5 录音状态机据此复位;正常发送再在上传完成后补发真实 URL(复刻 Android upload()+reset() 双回投)。
|
||||
// 缺这次空回投会导致 H5 收到真实 URL 也不处理 → 录完不播放。
|
||||
this.emitAudioUrl('', 0);
|
||||
if (action === 'send') {
|
||||
const key: string = this.recorder.key();
|
||||
this.recorder.stop().then((filePath: string) => this.doUpload(filePath, key, timeSec));
|
||||
} else {
|
||||
this.recorder.cancel();
|
||||
this.emitAudioUrl('', 0);
|
||||
}
|
||||
}
|
||||
|
||||
private async doUpload(filePath: string, key: string, timeSec: number): Promise<void> {
|
||||
const ctx: common.UIAbilityContext | undefined = this.context;
|
||||
if (ctx === undefined || filePath === '') {
|
||||
this.emitAudioUrl('', 0);
|
||||
return;
|
||||
return; // 已发过空回投(reset 语义);上传不了则保持"无语音"
|
||||
}
|
||||
try {
|
||||
const token: string = await QiniuToken.uploadToken();
|
||||
@@ -400,12 +402,10 @@ export class AudioProvider implements CapabilityProvider {
|
||||
if (ok) {
|
||||
this.emitAudioUrl(`http://gameaudio.daoqi88.cn/${key}`, timeSec);
|
||||
} else {
|
||||
this.log.w(`qiniu upload failed key=${key}`);
|
||||
this.emitAudioUrl('', 0);
|
||||
this.log.w(`qiniu upload failed key=${key}`); // 已发空回投,不再重复
|
||||
}
|
||||
} catch (e) {
|
||||
this.log.w(`upload error: ${(e as BusinessError).message}`);
|
||||
this.emitAudioUrl('', 0);
|
||||
this.log.w(`upload error: ${(e as BusinessError).message}`); // 已发空回投,不再重复
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user