MUSIC
Creating Sensors
const music = hmSensor.createSensor(hmSensor.id.MUSIC)
MUSIC instance
music: object
Properties | Description | Type |
---|---|---|
artist | artist name | string |
title | music name | string |
isPlaying | Play status true : playing, false : not playing | boolean |
music.audInit()
Initialize music controls
Type
() => void
music.audPlay()
Play
Type
() => void
music.audPause()
Pause
Type
() => void
music.audPrev()
Previous
Type
() => void
music.audNext()
Next
Type
() => void
Registering sensor instance callback events
music.addEventListener(event, callback: Callback)
The events of CHANGE
The value of event
hmSensor.event.CHANGE
Callback
() => void
The example of events
music.addEventListener(hmSensor.event.CHANGE, function () {
console.log("The current song's name: " + music.title + '\r\n')
})
Code example
const music = hmSensor.createSensor(hmSensor.id.MUSIC)
music.audInit()
music.audPlay()
music.audPause()
music.audPrev()
music.audNext()
console.log('The artist of song: ' + music.artist)
console.log('The name of song: ' + music.title)