HarmonyOS鸿蒙Next中TextReader.Person参数无法播放问题

HarmonyOS鸿蒙Next中TextReader.Person参数无法播放问题

真机环境:Mate60pro,5.0.0.155

加了Person参数之后就不能播放了,有大佬遇到吗?

根据这个网页设置的参数 https://developer.huawei.com/consumer/cn/doc/harmonyos-references/speech-textreader-api#section114621915195719

const readerParam: TextReader.ReaderParam = {
    keepBackgroundRunning: true,
    isVoiceBrandVisible: true,
    isFastForward: false,
    // reportProgressPeriod:
    // isMinibarNeeded: false,
    person: { tone: 0, style: "reading" },
    businessBrandInfo: {
        panelName: '小艺朗读',
        // panelIcon: $r('app.media.app_icon')
    },
}

try {
    await TextReader.init(getContext(this), readerParam);
} catch (err) {
    console.error(`TextReader failed to init. Code: ${err.code}, message: ${err.message}`);
}

更多关于HarmonyOS鸿蒙Next中TextReader.Person参数无法播放问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

在HarmonyOS鸿蒙Next中,TextReader.Person参数无法播放问题可能与API调用方式或参数传递错误有关。请检查TextReader的初始化及Person参数的设置,确保参数格式正确。另需确认设备是否支持该功能及系统版本是否兼容。若问题依旧,建议查阅官方API文档,确保调用方法无误。

更多关于HarmonyOS鸿蒙Next中TextReader.Person参数无法播放问题的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


根据您提供的代码和描述,TextReader在设置person参数后无法播放的问题可能有以下几个原因:

  1. 参数验证问题:
  • person参数中的style值"reading"需要确认是否在支持的枚举范围内(当前文档显示支持"reading"、"storytelling"等)
  1. 初始化顺序问题:
  • 建议先调用init()后再设置person参数,或者尝试在init()之后调用setPerson()方法单独设置
  1. 权限检查:
  • 确保已申请ohos.permission.READ_MEDIA权限
  • 检查是否开启了语音引擎服务
  1. 设备兼容性:
  • Mate60pro的5.0.0.155版本可能存在特定兼容性问题,建议检查是否有系统更新

建议先移除person参数测试基础功能是否正常,再逐步添加配置。如果问题依旧,可以尝试使用默认参数初始化后再通过setPerson()方法设置。

回到顶部