智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/1a/1aaa6f265afa4dd9b9f3870cdf3...

46 lines
949 B

function operateAudioPlayer (audioId, pageId, type, data) {
UniServiceJSBridge.publishHandler(pageId + '-audio-' + audioId, {
audioId,
type,
data
}, pageId)
}
class AudioContext {
constructor (id, pageId) {
this.id = id
this.pageId = pageId
}
setSrc (src) {
operateAudioPlayer(this.id, this.pageId, 'setSrc', {
src
})
}
play () {
operateAudioPlayer(this.id, this.pageId, 'play')
}
pause () {
operateAudioPlayer(this.id, this.pageId, 'pause')
}
seek (position) {
operateAudioPlayer(this.id, this.pageId, 'seek', {
position
})
}
}
export function createAudioContext (id, context) {
if (context) {
return new AudioContext(id, context.$page.id)
}
const app = getApp()
if (app.$route && app.$route.params.__id__) {
return new AudioContext(id, app.$route.params.__id__)
} else {
UniServiceJSBridge.emit('onError', 'createAudioContext:fail')
}
}