ionic4 - Ionic 4 Radio Streaming App 与 icecast2 背景模式和 Audio() 网络功能
问题描述
实际上,我有一个带有背景模式插件和音频的 Audio() HTML5 函数的 ionic 4 实现。(音频源是带有 aacplus 的 icecast 2.4.4 服务器)。
在我尝试使用 Cordova Media 插件但不支持 icecast 之前。
我有一些问题:
当手机未连接电池(或充电)时,如果手机被阻塞,则 5 分钟后音频停止,如果未连接(充电)但您正在使用该应用程序,则不会。
我的代码是这样的:
this.global.streamingAndroid = new Audio();
this.global.streamingAndroid.controls = true;
this.global.streamingAndroid.src = this.streamingUrl+'&vapp='+Math.random();
this.global.streamingAndroid.load();
this.global.streamingAndroid.play();
...
this.backgroundMode.enable();
this.backgroundMode.setDefaults({ silent: true });
// this.backgroundMode.disableWebViewOptimizations();
// this.backgroundMode.disableBatteryOptimizations();
this.backgroundMode.on('activate').subscribe(() => {
this.backgroundMode.disableWebViewOptimizations();
this.backgroundMode.disableBatteryOptimizations();
});
解决方案
推荐阅读
- python - 如果成员没有权限,如何显示错误消息?不和谐.py
- javascript - 箭头函数中的 +x 如何返回一个数字数组?
- python - 在 discord.py 中从“int”连接到字符串
- php - 用户名未插入且关系中断
- c# - 对带有换行符的字符串使用 string.Format 时出错
- hibernate - cascadetypes 中缺少 CascadeType.LOCK、CascadeType.REPLICATE、CascadeType.SAVE_UPDATE
- django - 如何从一个视图中在每个模板中显示 django 成功消息?
- reactjs - 如何在不使用 setTimeout 的情况下从我的 axios 请求中获取数据?
- node.js - 嗨,聪明的人,我对(多对多)与 sequelize orm 的关联有疑问
- python - 运行soup findall循环时出现异常