- Print
Accessibility
- Print
Accessibility Module 0.8.1
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.
Usage
To use the Accessibility module, you can import it into your project from the Firebolt SDK:
import { Accessibility } from '@firebolt-js/sdk'
Methods
closedCaptions
This API is deprecated since version 0.6.0. Use Accessibility.closedCaptionsSettings()
instead.
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"
}
}
}
closedCaptionsSettings
Get the user's preferred closed-captions settings
To get the value, call the method with no parameters:
function closedCaptionsSettings(): 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.closedCaptionsSettings()
.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.closedCaptionsSettings",
"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"
}
}
}
To subscribe to notifications when the value changes, pass a function as the only parameter:
function closedCaptionsSettings(subscriber: (closedCaptionsSettings: ClosedCaptionsSettings) => void): Promise<boolean>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
subscriber | Function | Yes | A callback that gets invoked when the value for closedCaptionsSettings changes |
Promise resolution:
Type | Summary |
---|---|
listenerId | The id of the listener that can be used with Accessibility.clear(listenerId) to unsubscribe |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
closedCaptionsSettings | ClosedCaptionsSettings | Yes | the closed captions settings |
Examples
Getting the closed captions settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.closedCaptionsSettings(closedCaptionsSettings => {
// property value was changed
console.log(closedCaptionsSettings)
}).then(listenerId => {
// you can clear this listener w/ Accessibility.clear(listenerId)
})
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.onClosedCaptionsSettingsChanged",
"params": {
"listen": true
}
}
Response:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"listening": "true"
}
}
{
"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
Listen for events from this module.
To listen to a specific event pass the event name as the first parameter:
Accessibility.listen(event: string, (data: any) => void): Promise<number>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
event | string | Yes | The event to listen for, see Events. |
callback | function | Yes | A function that will be invoked when the event occurs. |
Promise resolution:
Type | Description |
---|---|
number | Listener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
data | any | Yes | The event data, which depends on which event is firing, see Events. |
To listen to all events from this module pass only a callback, without specifying an event name:
Accessibility.listen((event: string, data: any) => void): Promise<number>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
callback | function | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events. |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
event | string | Yes | The event that has occured listen for, see Events. |
data | any | Yes | The event data, which depends on which event is firing, see Events. |
Promise resolution:
Type | Description |
---|---|
number | Listener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
See Listening for events for more information and examples.
once
Listen for only one occurance of an event from this module. The callback will be cleared after one event.
To listen to a specific event pass the event name as the first parameter:
Accessibility.once(event: string, (data: any) => void): Promise<number>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
event | string | Yes | The event to listen for, see Events. |
callback | function | Yes | A function that will be invoked when the event occurs. |
Promise resolution:
Type | Description |
---|---|
number | Listener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
data | any | Yes | The event data, which depends on which event is firing, see Events. |
To listen to all events from this module pass only a callback, without specifying an event name:
Accessibility.once((event: string, data: any) => void): Promise<number>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
callback | function | Yes | A function that will be invoked when the event occurs. The event data depends on which event is firing, see Events. |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
event | string | Yes | The event that has occured listen for, see Events. |
data | any | Yes | The event data, which depends on which event is firing, see Events. |
Promise resolution:
Type | Description |
---|---|
number | Listener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id) |
See Listening for events for more information and examples.
voiceGuidance
This API is deprecated since version 0.6.0. Use Accessibility.voiceGuidanceSettings()
instead.
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
}
}
voiceGuidanceSettings
Get the user's preferred voice guidance settings
To get the value, call the method with no parameters:
function voiceGuidanceSettings(): 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.voiceGuidanceSettings()
.then(settings => {
console.log(settings)
})
Value of settings
:
{
"enabled": true,
"speed": 5
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.voiceGuidanceSettings",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 5
}
}
To subscribe to notifications when the value changes, pass a function as the only parameter:
function voiceGuidanceSettings(subscriber: (settings: VoiceGuidanceSettings) => void): Promise<boolean>
Parameters:
Param | Type | Required | Summary |
---|---|---|---|
subscriber | Function | Yes | A callback that gets invoked when the value for voiceGuidanceSettings changes |
Promise resolution:
Type | Summary |
---|---|
listenerId | The id of the listener that can be used with Accessibility.clear(listenerId) to unsubscribe |
Callback parameters:
Param | Type | Required | Summary |
---|---|---|---|
settings | VoiceGuidanceSettings | Yes | the voice guidance settings |
Examples
Getting the voice guidance settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.voiceGuidanceSettings(settings => {
// property value was changed
console.log(settings)
}).then(listenerId => {
// you can clear this listener w/ Accessibility.clear(listenerId)
})
value of settings
:
{
"enabled": true,
"speed": 5
}
JSON-RPC:
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "accessibility.onVoiceGuidanceSettingsChanged",
"params": {
"listen": true
}
}
Response:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"listening": "true"
}
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 5
}
}
Events
Additional events
The following events are documented as part of a related set of method APIs.
For more information, follow the links under the "Documentation" column.
JavaScript | RPC | Payload | Documentation |
---|---|---|---|
closedCaptionsSettingsChanged | onClosedCaptionsSettingsChanged | ClosedCaptionsSettings | closedCaptionsSettings |
voiceGuidanceSettingsChanged | onVoiceGuidanceSettingsChanged | VoiceGuidanceSettings | voiceGuidanceSettings |
Schemas
ClosedCaptionsStyles
The default styles to use when displaying closed-captions
type ClosedCaptionsStyles = {
fontFamily?: string
fontSize?: number
fontColor?: string
fontEdge?: string
fontEdgeColor?: string
fontOpacity?: number
backgroundColor?: string
backgroundOpacity?: number
textAlign?: string
textAlignVertical?: string
}
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
}