SystemSounds
Start from API_LEVEL
3.6
. Please refer to API_LEVEL.
Calorie Sensor.
Methods
getEnabled
Get whether the system ringtone function is turned on, and it can only be played after it is turned on
getEnabled(): boolean
getSourceType
Get built-in system ringtone type
getSourceType(): Type
Type
Property | Type | Required | DefaultValue | Description | API_LEVEL |
---|---|---|---|---|---|
ALARM | number | Y | - | Alarm clock reminder | 3.6 |
MESSAGE | number | Y | - | Notification sound when receiving text messages or emails | 3.6 |
REGULAR | number | Y | - | TingTing sound | 3.6 |
ACHIEVE | number | Y | - | Goals achieved | 3.6 |
CAMERA | number | Y | - | Camera shutter | 3.6 |
ABN_HIGH | number | Y | - | Health data measurement abnormalities (high values) | 3.6 |
ABN_LOW | number | Y | - | Health data measurement abnormalities (low values) | 3.6 |
SOS | number | Y | - | SOS for help | 3.6 |
start
Start playing the sound, you can pass in type
to specify the ringtone type, repeatCount
is the number of audio repetitions, default is 0
, do not repeat playback
start(sourceType: number, repeatCount: 0): void
stop
Stop sound playback
stop(): void
Example
import { SystemSounds } from '@zos/sensor'
const systemSounds = new SystemSounds()
const alarmType = systemSounds.getSourceType().ALARM
if (systemSounds.getEnabled()) {
systemSounds.start(alarmType)
}