BackgroundAudioManager
解释:swan.getBackgroundAudioManager的返回值。
方法参数
backgroundAudioManager类的属性列表 :
示例
在开发者工具中预览效果
扫码体验
请使用百度APP扫码
图片示例
代码示例
-
Page({ onLoad() { const backgroundAudioManager = swan.getBackgroundAudioManager(); console.log('backgroundAudioManager:', backgroundAudioManager) backgroundAudioManager.title = '演员'; backgroundAudioManager.epname = '演员'; backgroundAudioManager.singer = '薛之谦'; backgroundAudioManager.coverImgUrl = 'https://c.hiphotos.baidu.com/super/pic/item/8b13632762d0f703e34c0f6304fa513d2797c597.jpg'; backgroundAudioManager.onPlay(res => { swan.showToast({ title: 'play', icon: 'none' }); console.log('onPlay', res); }); backgroundAudioManager.onPause(res => { swan.showToast({ title: 'pause', icon: 'none' }); console.log('onPause', res); }); backgroundAudioManager.onStop(res => { swan.showToast({ title: 'stop', icon: 'none' }); console.log('onStop', res); }); backgroundAudioManager.onEnded(res => { swan.showToast({ title: 'end', icon: 'none' }); console.log('onEnded', res); }); backgroundAudioManager.onTimeUpdate(res => { console.log('onTimeUpdate', res); }); backgroundAudioManager.onError(res => { swan.showToast({ title: 'error', icon: 'none' }); console.log('onError', res); }); backgroundAudioManager.onWaiting(res => { swan.showToast({ title: 'waiting', icon: 'none' }); console.log('onWaiting', res); }); backgroundAudioManager.onSeeked(res => { swan.showToast({ title: 'onSeeked', icon: 'none' }); console.log('onSeeked', res); }); backgroundAudioManager.onSeeking(res => { swan.showToast({ title: 'onSeeking', icon: 'none' }); console.log('onSeeking', res); }); backgroundAudioManager.onNext(res => { swan.showToast({ title: 'onNext', icon: 'none' }); console.log('onNext', res); }); backgroundAudioManager.onPrev(res => { swan.showToast({ title: 'onPrev', icon: 'none' }); console.log('onPrev', res); }); this.backgroundAudioManager = backgroundAudioManager; }, play() { this.backgroundAudioManager.src = 'https://vd3.bdstatic.com/mda-ic7mxzt5cvz6f4y5/mda-ic7mxzt5cvz6f4y5.mp3'; this.backgroundAudioManager.play(); }, pause() { this.backgroundAudioManager.pause(); }, stop() { this.backgroundAudioManager.stop(); }, seek() { this.backgroundAudioManager.seek(10); }});
