Skip to main content
Version: 0.8.0

Accessibility Module


Version 0.8.0

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.

OpenRPC

Firebolt APIs are maintained in the rdkcentral/firebolt-core-sdk GitHub repository.

You can see this API in the accessibility.json OpenRPC JSON-Schema document.

Table of Contents

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:

TypeDescription
ClosedCaptionsSettingsthe 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:

TypeDescription
ClosedCaptionsSettingsthe 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:

ParamTypeRequiredSummary
subscriberFunctionYesA callback that gets invoked when the value for closedCaptionsSettings changes

Promise resolution:

TypeSummary
listenerIdThe id of the listener that can be used with Accessibility.clear(listenerId) to unsubscribe

Callback parameters:

ParamTypeRequiredSummary
closedCaptionsSettingsClosedCaptionsSettingsYesthe 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:

ParamTypeRequiredSummary
eventstringYesThe event to listen for, see Events.
callbackfunctionYesA function that will be invoked when the event occurs.

Promise resolution:

TypeDescription
numberListener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id)

Callback parameters:

ParamTypeRequiredSummary
dataanyYesThe 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:

ParamTypeRequiredSummary
callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

ParamTypeRequiredSummary
eventstringYesThe event that has occured listen for, see Events.
dataanyYesThe event data, which depends on which event is firing, see Events.

Promise resolution:

TypeDescription
numberListener 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:

ParamTypeRequiredSummary
eventstringYesThe event to listen for, see Events.
callbackfunctionYesA function that will be invoked when the event occurs.

Promise resolution:

TypeDescription
numberListener ID to clear the callback method and stop receiving the event, e.g. Accessibility.clear(id)

Callback parameters:

ParamTypeRequiredSummary
dataanyYesThe 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:

ParamTypeRequiredSummary
callbackfunctionYesA function that will be invoked when the event occurs. The event data depends on which event is firing, see Events.

Callback parameters:

ParamTypeRequiredSummary
eventstringYesThe event that has occured listen for, see Events.
dataanyYesThe event data, which depends on which event is firing, see Events.

Promise resolution:

TypeDescription
numberListener 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:

TypeDescription
VoiceGuidanceSettingsthe 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:

TypeDescription
VoiceGuidanceSettingsthe 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:

ParamTypeRequiredSummary
subscriberFunctionYesA callback that gets invoked when the value for voiceGuidanceSettings changes

Promise resolution:

TypeSummary
listenerIdThe id of the listener that can be used with Accessibility.clear(listenerId) to unsubscribe

Callback parameters:

ParamTypeRequiredSummary
settingsVoiceGuidanceSettingsYesthe 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.

JavaScriptRPCPayloadDocumentation
closedCaptionsSettingsChangedonClosedCaptionsSettingsChangedClosedCaptionsSettingsclosedCaptionsSettings
voiceGuidanceSettingsChangedonVoiceGuidanceSettingsChangedVoiceGuidanceSettingsvoiceGuidanceSettings

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
}