|
|
@@ -9,6 +9,7 @@ import {
|
|
|
server_url
|
|
|
} from '@/utils/config.js'
|
|
|
var wv;
|
|
|
+const bgAudioManager = uni.getBackgroundAudioManager();
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
@@ -109,22 +110,22 @@ export default {
|
|
|
console.log('8秒内重复调用,跳过本次播放');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- let bgAudioManager;
|
|
|
- if (this.bgAudioManager) {
|
|
|
- bgAudioManager = this.bgAudioManager;
|
|
|
- } else {
|
|
|
- this.bgAudioManager = uni.getBackgroundAudioManager();
|
|
|
- bgAudioManager = this.bgAudioManager;
|
|
|
- }
|
|
|
-
|
|
|
- // 更新上次播放时间
|
|
|
- this.lastPlayTime = now;
|
|
|
+ console.log('调用语音播放');
|
|
|
|
|
|
bgAudioManager.title = '报警播报';
|
|
|
bgAudioManager.singer = '暂无';
|
|
|
bgAudioManager.coverImgUrl = 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/music-a.png';
|
|
|
bgAudioManager.src = url;
|
|
|
+ bgAudioManager.play()
|
|
|
+ bgAudioManager.onPlay(() => {
|
|
|
+ console.log('开始播放');
|
|
|
+ });
|
|
|
+
|
|
|
+ bgAudioManager.onError((res) => {
|
|
|
+ console.log('播放错误', res);
|
|
|
+ });
|
|
|
+ // 更新上次播放时间
|
|
|
+ // this.lastPlayTime = now;
|
|
|
|
|
|
} catch (error) {
|
|
|
//TODO handle the exception
|