Lullaby
Pre-requisite: The user has to be signed in, and the camera should support the lullaby feature.
The lullaby player lives on the camera. There are three ways to reach it, and an app normally uses all three:
| Use it for | Needs a live stream? | |
|---|---|---|
Settings on Factory.babyService | The persisted defaults — track, mode, timer — and the current state | No |
Cloud control on Factory.deviceService | Play / pause / resume / stop from a screen without video | No |
| Wrappers on the live view object | The same calls from a live-view screen, using the object’s spaceId / deviceId | No — they are REST wrappers, not data-channel commands |
Whichever path issues a command, the resulting playback state arrives asynchronously on InstaSDK.shared.onSSEMessage as an SSEMessage whose payload is .lullabyStateUpdated(SSELullabyStateMessage) (deviceId, spaceId, playbackState, optional trackId). Render the player from that message rather than assuming a command succeeded. PlaybackState is playing, paused, resumed or stopped.
LiveViewModel also exposes three @Published flags — showLullabyPlayer, playLullaby, stopLullaby — for an app to drive its own player UI; the SDK never sets them.
LullabyPlayRequest carries the trackId, the playbackMode and the timerDurationMins; LullabySettingsModel returns them together with the playbackState and playbackStartedAt.
Tracks, modes and timers
Each camera model reports what its player supports. Read it once per model with deviceModelInfo and build the picker from the result:
Factory.deviceService.deviceModelInfo(spaceId: spaceId, deviceId: deviceId)
// -> DeviceModelInfo.modelDetails?.properties?.lullaby : LullabyProperty?
// .supportedTracks : [LullabyTrack] – id, name, description → trackId
// .supportedModes : [String] → playbackMode
// .supportedTimers : [Int] → timerDurationMins
The current catalogue is 17 tracks:
trackId | Name | Description |
|---|---|---|
track_1 | White Noise | Even hiss across the spectrum |
track_2 | Pink Noise | Softer, balanced shhh |
track_3 | Brown Noise | Deep, rumbly low end |
track_4 | Gentle Rain | Soft pattering rainfall |
track_5 | Ocean Waves | Rolling shoreline waves |
track_6 | Forest Breeze | Wind through the trees |
track_7 | Twinkle Twinkle | Twinkle, Twinkle, Little Star |
track_8 | Brahms’ Lullaby | Gentle bedtime classic |
track_9 | Rock-a-bye Baby | Traditional cradle song |
track_10 | White Noise 1 | Even hiss across the spectrum |
track_11 | White Noise 2 | Even hiss across the spectrum |
track_12 | Twinkle Twinkle Little Stars | Twinkle Twinkle Little Stars |
track_13 | Piano Song | Piano Song |
track_14 | Hust Little Baby | Hust Little Baby |
track_15 | Finger | Finger |
track_16 | Silent Night | Silent Night |
track_17 | Sleep Lullaby | Sleep Lullaby |
Tracks 1–6 are ambient sounds, 7–9 and 12–17 are songs; track_10 / track_11 are alternate white-noise renditions. Prefer supportedTracks from the model over this list — older firmware may carry fewer.
Settings
Get Lullaby Settings
To fetch the current lullaby settings for a device, The following method can be used:
spaceId(required): The space ID of the User.deviceId(required): The ID of the device.
Factory.babyService.getLullabySettings(
spaceId: String,
deviceId: String
) -> IVPublisher<LullabySettingsModel>
Update Lullaby Settings
To update the lullaby settings for a device, The following method can be used:
spaceId(required): The space ID of the User.deviceId(required): The ID of the device.request(required): Contains updated lullaby settings.
Factory.babyService.updateLullabySettings(
spaceId: String,
deviceId: String,
request: LullabyPlayRequest
) -> IVPublisher<LullabySettingsModel>
Cloud control
These calls reach the camera through the backend, so they work from any screen. Each takes:
spaceId(required): The space ID of the User.deviceId(required): The ID of the device.request(optional, play only): The track id, the playback mode and the timer duration.
Factory.deviceService.playLullaby(spaceId: String, deviceId: String, request: LullabyPlayRequest?) -> IVPublisher<Void>
Factory.deviceService.pauseLullaby(spaceId: String, deviceId: String) -> IVPublisher<Void>
Factory.deviceService.resumeLullaby(spaceId: String, deviceId: String) -> IVPublisher<Void>
Factory.deviceService.stopLullaby(spaceId: String, deviceId: String) -> IVPublisher<Void>
Live-view wrappers
LiveViewModel carries the same four commands so a live-view screen can call them without repeating the ids. They issue the Factory.deviceService calls above — nothing travels over the stream, and the stream does not need to be connected.
request(optional, play only): The track id, the playback mode and the timer duration.
liveViewObject.lullabyPlay(request: LullabyPlayRequest?)
liveViewObject.lullabyPause()
liveViewObject.lullabyResume()
liveViewObject.lullabyStoped()