- Print
Accessibility
- Print
Accessibility Module 0.15.0
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.
Methods
audioDescriptionSettings
Get the user's preferred audio description settings
To get the value of audioDescriptionSettings
call the method like this:
function audioDescriptionSettings(): Promise<AudioDescriptionSettings>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:accessibility:audiodescriptions |
Examples
Getting the audio description settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
Accessibility.audioDescriptionSettings()
.then(settings => {
console.log(settings)
})
Value of settings
:
{
"enabled": true
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.audioDescriptionSettings",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true
}
}
To subscribe to notifications when the value changes, call the method like this:
function audioDescriptionSettings(callback: (value) => AudioDescriptionSettings): Promise<number>
Promise resolution:
number
Examples
Getting the audio description settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
audioDescriptionSettings(value => {
console.log(value)
}).then(listenerId => {
console.log(listenerId)
})
Value of settings
:
{
"enabled": true
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.onAudioDescriptionSettingsChanged",
"params": {
"listen": true
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true
}
}
closedCaptions
Get the user's preferred closed-captions settings
function closedCaptions(): Promise<ClosedCaptionsSettings>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:accessibility:closedcaptions |
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",
"windowColor": "white",
"windowOpacity": 50
}
}
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",
"windowColor": "white",
"windowOpacity": 50
}
}
}
closedCaptionsSettings
Get the user's preferred closed-captions settings
To get the value of closedCaptionsSettings
call the method like this:
function closedCaptionsSettings(): Promise<ClosedCaptionsSettings>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:accessibility:closedcaptions |
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",
"windowColor": "white",
"windowOpacity": 50
}
}
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",
"windowColor": "white",
"windowOpacity": 50
}
}
}
To subscribe to notifications when the value changes, call the method like this:
function closedCaptionsSettings(callback: (value) => ClosedCaptionsSettings): Promise<number>
Promise resolution:
number
Examples
Getting the closed captions settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
closedCaptionsSettings(value => {
console.log(value)
}).then(listenerId => {
console.log(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",
"windowColor": "white",
"windowOpacity": 50
}
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.onClosedCaptionsSettingsChanged",
"params": {
"listen": true
}
}
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",
"windowColor": "white",
"windowOpacity": 50
}
}
}
listen
To listen to a specific event pass the event name as the first parameter:
listen(event: string, callback: (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:
listen(callback: (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
To listen to a single instance of a specific event pass the event name as the first parameter:
once(event: string, callback: (data: any) => void): Promise<number>
The once
method will only pass the next instance of this event, and then dicard the listener you provided.
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 the next instance only of any events from this module pass only a callback, without specifying an event name:
once(callback: (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
Get the user's preferred voice guidance settings
function voiceGuidance(): Promise<VoiceGuidanceSettings>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:accessibility:voiceguidance |
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": 2
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.voiceGuidance",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 2
}
}
voiceGuidanceSettings
Get the user's preferred voice guidance settings
To get the value of voiceGuidanceSettings
call the method like this:
function voiceGuidanceSettings(): Promise<VoiceGuidanceSettings>
Promise resolution:
Capabilities:
Role | Capability |
---|---|
uses | xrn:firebolt:capability:accessibility:voiceguidance |
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": 2
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.voiceGuidanceSettings",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 2
}
}
To subscribe to notifications when the value changes, call the method like this:
function voiceGuidanceSettings(callback: (value) => VoiceGuidanceSettings): Promise<number>
Promise resolution:
number
Examples
Getting the voice guidance settings
JavaScript:
import { Accessibility } from '@firebolt-js/sdk'
voiceGuidanceSettings(value => {
console.log(value)
}).then(listenerId => {
console.log(listenerId)
})
Value of settings
:
{
"enabled": true,
"speed": 2
}
JSON-RPC:
Request:{
"jsonrpc": "2.0",
"id": 1,
"method": "Accessibility.onVoiceGuidanceSettingsChanged",
"params": {
"listen": true
}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"enabled": true,
"speed": 2
}
}
Events
audioDescriptionSettingsChanged
closedCaptionsSettingsChanged
voiceGuidanceSettingsChanged
Types
AudioDescriptionSettings
type AudioDescriptionSettings = {
enabled: boolean // Whether or not audio descriptions should be enabled by default
}