beefast-mini-deliveryman/pages/test/audio.js
2025-03-01 02:00:47 +08:00

94 lines
1.9 KiB
JavaScript

// pages/test/audio.js
Page({
/**
* 页面的初始数据
*/
data: {
time:0
},
gbam:null,
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.bgam = wx.getBackgroundAudioManager();
this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/empty.mp3';
this.bgam.title = '后台通知';
this.bgam.audioType = 'music';
this.bgam.coverImgUrl = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/20250227/DoADoEhKi4U4ab75d180b27fa14b7c34ae7969762809_d7ee9018-828e-43c7-8b2b-29d4352c0277.jpg?imageMogr2/thumbnail/800x800/format/webp';
this.bgam.play();
this.bgam.onPlay();
this.bgam.onEnded(()=>{
console.log('end');
// this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/empty.mp3';
// this.bgam.play();
})
// const innerAudioContext = wx.createInnerAudioContext({
// useWebAudioImplement:true
// })
// innerAudioContext.src = '/assets/audio/order_complete.wav';
// innerAudioContext.play();
},
playAudio(){
setInterval(()=>{
this.setData({
time:this.data.time+1
});
},1000);
setInterval(()=>{
this.bgam.src = 'https://dman-1311994147.cos.ap-chengdu.myqcloud.com/static/new_order.mp3';
this.bgam.play();
},10000)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})