创建AVSession代码如下:
let type: AVSessionManager.AVSessionType = 'audio';
let session = await AVSessionManager.createAVSession(this.context, 'AUDIO_NEWS', type);
// 激活接口要在元数据、控制命令注册完成之后再执行
await session.activate();
console.info(`session create done : sessionId : ${session.sessionId}`);
一个UIAbility只能存在一个媒体会话,重复创建会失败。请检查代码中销毁媒体会话方法的调用位置是否合适。相关文档请参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides...