HarmonyOS鸿蒙Next中just_audio报不支持disposeAllPlayers
HarmonyOS鸿蒙Next中just_audio报不支持disposeAllPlayers pubspec.yaml:
just_audio:
git:
url: https://gitcode.com/openharmony-sig/fluttertpc_just_audio.git
path: just_audio
当执行:
await _audioPlayer.setAudioSource(AudioSource.file(fi.file.path));
报错误:
MissingPluginException(No implementation found for method disposeAllPlayers on channel com.ryanheise.just_audio.methods)
但是,插件页面(https://gitcode.com/openharmony-sig/fluttertpc_just_audio/tree/br_v0.10.4_ohos#3-api)说支持。
那这个问题怎么解决?
更多关于HarmonyOS鸿蒙Next中just_audio报不支持disposeAllPlayers的实战教程也可以访问 https://www.itying.com/category-93-b0.html
开发者您好,插件页面为0.10.4分支,需要您在配置时指定分支,如果不指定则是默认分支。如果使用0.10.4分支请指定ref,pubspec.yaml:
just_audio:
git:
url: https://gitcode.com/openharmony-sig/fluttertpc_just_audio.git
path: just_audio
ref: br_v0.10.4_ohos
更多关于HarmonyOS鸿蒙Next中just_audio报不支持disposeAllPlayers的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
是不是版本问题呀?
在鸿蒙Next上,just_audio插件的disposeAllPlayers方法依赖Android/iOS底层API,而鸿蒙平台未实现对应接口,因此不支持。需等待插件官方更新适配。
该报错说明 just_audio 的 OpenHarmony 平台通道未实现 disposeAllPlayers 方法,导致 setAudioSource 内部触发该方法后抛出 MissingPluginException。虽然文档标识支持,但实际您使用的 br_v0.10.4_ohos 分支可能尚未完整实现全部通道调用。
直接解决办法:
- 替换为专用的
just_audio_ohos包。- 移除
pubspec.yaml中原有的just_audio依赖,改用:dependencies: just_audio_ohos: ^0.10.5 - 该包专门适配 OpenHarmony,已完成所有通道实现,直接可用。
- 移除
- 如仍需使用原有 Git 依赖,则需更新至最新 ohos 分支或自行在
ohos/工程中补全disposeAllPlayers的平台实现。
推荐直接切换至 just_audio_ohos,可立即解决问题。

