SoundPlayer
caution
This service is rc and may change in the future.
A device that can play various sounds stored locally. This service is typically paired with a storage
service for storing sounds.
import { SoundPlayer } from "@devicescript/core"
const soundPlayer = new SoundPlayer()
Commands
play
Starts playing a sound.
soundPlayer.play(name: string): Promise<void>
cancel
Cancel any sound playing.
soundPlayer.cancel(): Promise<void>
Registers
intensity
Global volume of the output. 0
means completely off. This volume is mixed with each play volumes.
type:
Register<number>
(packing formatu0.16
)optional: this register may not be implemented
read and write
import { SoundPlayer } from "@devicescript/core"
const soundPlayer = new SoundPlayer()
// ...
const value = await soundPlayer.intensity.read()
await soundPlayer.intensity.write(value)
- track incoming values
import { SoundPlayer } from "@devicescript/core"
const soundPlayer = new SoundPlayer()
// ...
soundPlayer.intensity.subscribe(async (value) => {
...
})
note
write
and read
will block until a server is bound to the client.