后台持续播放无声音频,流氓做法实现
在app.vue里初始化
<script>
import Vue from 'vue';
let AUDIO = uni.createInnerAudioContext()
export default {
// 司机端
onLaunch: function() {
this.initAudio(AUDIO)
console.log('App Launch');
uni.getSystemInfo({
success: e => {
// 状态栏高度px
Vue.prototype.statusHeight = e.statusBarHeight;
Vue.prototype.screenHeight = e.screenHeight;
Vue.prototype.screenWidth = e.screenWidth;
Vue.prototype.platform = e.platform;
Vue.prototype.widthRatio = e.screenWidth / 750;
Vue.prototype.AUDIO = AUDIO
}
});
// #ifdef MP
uni.setEnableDebug({
enableDebug: true
});
// #endif
},
onShow: function() {
// AUDIO.src = '/static/msg.mp3'
console.log('App Show');
},
onHide: function() {
console.log('App Hide');
},
methods:{
initAudio(AUDIO) {
let _this = this
console.log('初始化音频播放', AUDIO);
// onCanpl