小程序背景音乐

onLaunch: function () {
console.log( this)
this.AppMusic = wx.createInnerAudioContext();
this.AppMusic.autoplay = true;
this.AppMusic.loop = true;
this.AppMusic.onPlay(() => {
console.log( '开始播放')
})
this.AppMusic.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
},



// 从60s开始播放
app.AppMusic.seek( 60);
app.AppMusic.src = 'http://ovhvevt35.bkt.clouddn.com/photo/%E5%A5%BD%E5%A6%B9%E5%A6%B9%E4%B9%90%E9%98%9F%20-%20%E4%B8%8D%E8%AF%B4%E5%86%8D%E8%A7%81.mp3'

// music
music(e){
let that = this;
let status = e.currentTarget.dataset.status;
if (status){
app.AppMusic.pause();
app.AppMusic.onPause(() => {
console.log( '暂停播放');
that.setData({
status: false
})
})
} else{
app.AppMusic.play();
app.AppMusic.onPlay(() => {
console.log( '开始播放');
that.setData({
status: true
})
})
}
console.log(e)
},
// 上传图片音乐会暂停
upImg(){
wx.chooseImage({
success: function (res) {
var tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'https://example.weixin.qq.com/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[ 0],
name: 'file',
formData: {
'user': 'test'
},
success: function (res) {
var data = res.data
//do something
}
})
}
})
},
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值