- Print
Accessibility
- Print
Accessibility Module 0.5.3
Usage
To use the Accessibility module, you can import it into your project from the Firebolt SDK:
import { Accessibility } from '@firebolt-js/sdk'
Overview
The Accessibility
module provides access to the user/device settings for closed captioning and voice guidance.
Apps SHOULD attempt o respect these settings, rather than manage and persist seprate settings, which would be different per-app.
Events
closedCaptionsSettingsChanged
Subscribe to notifications with the user's preferred closed-captions settings
// listen to closedCaptionsSettingsChanged
Accessibility.listen('closedCaptionsSettingsChanged', (data: ClosedCaptionsSettings) => void): Promise<bigint>
// listen to closedCaptionsSettingsChanged once
Accessibility.once('closedCaptionsSettingsChanged', (data: ClosedCaptionsSettings) => void): Promise<bigint>
// clear a listener
Accessibility.clear(listenerId?: bigint): void
Event value
Type | Description |
---|---|
ClosedCaptionsSettings | the closed captions settings |
Promise Resolution
Type | Description |
---|---|
bigint | Listener ID to clear() the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
Examples
##### Getting the closed captions settings
JavaScript
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.listen('closedCaptionsSettingsChanged', settings => {
console.log(settings)
})
Value of settings
{
"enabled": true,
"styles": {
"fontFamily": "Monospace sans-serif",
"fontSize": 1,
"fontColor": "#ffffff",
"fontEdge": "none",
"fontEdgeColor": "#7F7F7F",
"fontOpacity": 100,
"backgroundColor": "#000000",
"backgroundOpacity": 100,
"textAlign": "center",
"textAlignVertical": "middle"
}
}
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.onClosedCaptionsSettingsChanged",
"params": {}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"styles": {
"fontFamily": "Monospace sans-serif",
"fontSize": 1,
"fontColor": "#ffffff",
"fontEdge": "none",
"fontEdgeColor": "#7F7F7F",
"fontOpacity": 100,
"backgroundColor": "#000000",
"backgroundOpacity": 100,
"textAlign": "center",
"textAlignVertical": "middle"
}
}
}
##### Listen to an event only once
JavaScript
Accessibility.listen('closedCaptionsSettingsChanged', (value) => {
console.log(value)
}).then( (listenerId) => {
Accessibility.clear(listenerId)
})
Alternately, simply call once()
:
Accessibility.once('closedCaptionsSettingsChanged', (value) => {
console.log(value)
})
##### Clear all listeners for an event
JavaScript
Accessibility.clear('closedCaptionsSettingsChanged')
voiceGuidanceSettingsChanged
Subscribe to notifications with the user's preferred voice guidance settings
// listen to voiceGuidanceSettingsChanged
Accessibility.listen('voiceGuidanceSettingsChanged', (data: VoiceGuidanceSettings) => void): Promise<bigint>
// listen to voiceGuidanceSettingsChanged once
Accessibility.once('voiceGuidanceSettingsChanged', (data: VoiceGuidanceSettings) => void): Promise<bigint>
// clear a listener
Accessibility.clear(listenerId?: bigint): void
Event value
Type | Description |
---|---|
VoiceGuidanceSettings | the voice guidance settings |
Promise Resolution
Type | Description |
---|---|
bigint | Listener ID to clear() the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
Examples
##### Getting the voice guidance settings
JavaScript
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.listen('voiceGuidanceSettingsChanged', settings => {
console.log(settings)
})
Value of settings
{
"enabled": true,
"speed": 5
}
JSON-RPC
Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.onVoiceGuidanceSettingsChanged",
"params": {}
}
Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 5
}
}
##### Listen to an event only once
JavaScript
Accessibility.listen('voiceGuidanceSettingsChanged', (value) => {
console.log(value)
}).then( (listenerId) => {
Accessibility.clear(listenerId)
})
Alternately, simply call once()
:
Accessibility.once('voiceGuidanceSettingsChanged', (value) => {
console.log(value)
})
##### Clear all listeners for an event
JavaScript
Accessibility.clear('voiceGuidanceSettingsChanged')
Methods
closedCaptions
Get the user's preferred closed-captions settings
function closedCaptions(): Promise<ClosedCaptionsSettings>
Promise Resolution
Type | Description |
---|---|
ClosedCaptionsSettings | the closed captions settings |
Examples
##### Getting the closed captions settings
JavaScript
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.closedCaptions()
.then(closedCaptionsSettings => {
console.log(closedCaptionsSettings)
})
Value of closedCaptionsSettings
{
"enabled": true,
"styles": {
"fontFamily": "Monospace sans-serif",
"fontSize": 1,
"fontColor": "#ffffff",
"fontEdge": "none",
"fontEdgeColor": "#7F7F7F",
"fontOpacity": 100,
"backgroundColor": "#000000",
"backgroundOpacity": 100,
"textAlign": "center",
"textAlignVertical": "middle"
}
}
JSON-RPC
###### Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.closedCaptions",
"params": {}
}
###### Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"styles": {
"fontFamily": "Monospace sans-serif",
"fontSize": 1,
"fontColor": "#ffffff",
"fontEdge": "none",
"fontEdgeColor": "#7F7F7F",
"fontOpacity": 100,
"backgroundColor": "#000000",
"backgroundOpacity": 100,
"textAlign": "center",
"textAlignVertical": "middle"
}
}
}
voiceGuidance
Get the user's preferred voice guidance settings
function voiceGuidance(): Promise<VoiceGuidanceSettings>
Promise Resolution
Type | Description |
---|---|
VoiceGuidanceSettings | the voice guidance settings |
Examples
##### Getting the voice guidance settings
JavaScript
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.voiceGuidance()
.then(settings => {
console.log(settings)
})
Value of settings
{
"enabled": true,
"speed": 5
}
JSON-RPC
###### Request
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.voiceGuidance",
"params": {}
}
###### Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 5
}
}
Schemas
ClosedCaptionsStyles
type ClosedCaptionsStyles = {
fontFamily?: string
fontSize?: number
fontColor?: string
fontEdge?: string
fontEdgeColor?: string
fontOpacity?: number
backgroundColor?: string
backgroundOpacity?: number
textAlign?: string
textAlignVertical?: string
}
Details
The default styles to use when displaying closed-captions
ClosedCaptionsSettings
type ClosedCaptionsSettings = {
enabled: boolean // Whether or not closed-captions should be enabled by default
styles: ClosedCaptionsStyles // The default styles to use when displaying closed-captions
}
VoiceGuidanceSettings
type VoiceGuidanceSettings = {
enabled: boolean // Whether or not voice guidance should be enabled by default
speed: number // The speed at which voice guidance speech will be read back to the user
}