Accessibility-0.10.0

    Accessibility-0.10.0


    Article summary


    title: Accessibility

    # Accessibility Module

    Version 0.10.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 of closedCaptionsSettings call the method like this:

    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 set the value of closedCaptionsSettings call the method like this:

    function closedCaptionsSettings(): Promise<ListenResponse | ClosedCaptionsSettings>
    

    Parameters:

    ParamTypeRequiredSummary

    Promise resolution:

    TypeSummary
    voidPromise resolves with no value when the operation is complete.

    Examples

    Getting the closed captions settings

    JavaScript:

    import { Accessibility } from '@firebolt-js/sdk'
    
    Accessibility.closedCaptionsSettings(true)
    
    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, call the method like this:

    function closedCaptionsSettings (subscriber: () => void): Promise<listenerId>
    

    Parameters:

    ParamTypeRequiredSummary
    ``
    subscriberfunctionYesCallback to execute when the value changes.

    Promise resolution:

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

    Callback parameters:

    ParamTypeRequiredSummary
    ```

    Examples

    JavaScript:

    import { Accessibility } from '@firebolt-js/sdk'
    
    Accessibility.closedCaptionsSettings((value) => {
      // property value was changed
      console.log(value)
    }).then(listenerId => {
      // you can clear this listener w/ Accessibility.clear(listenerId)
    })
    

    value of value:

    JSON-RPC:

    Request:

    Response:

    {
      "jsonrpc": "2.0",
      "id": "1",
      "result": {
        "listening": "true"
      }
    }
    

    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 of voiceGuidanceSettings call the method like this:

    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 set the value of voiceGuidanceSettings call the method like this:

    function voiceGuidanceSettings(): Promise<ListenResponse | VoiceGuidanceSettings>
    

    Parameters:

    ParamTypeRequiredSummary

    Promise resolution:

    TypeSummary
    voidPromise resolves with no value when the operation is complete.

    Examples

    Getting the voice guidance settings

    JavaScript:

    import { Accessibility } from '@firebolt-js/sdk'
    
    Accessibility.voiceGuidanceSettings(true)
    
    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, call the method like this:

    function voiceGuidanceSettings (subscriber: () => void): Promise<listenerId>
    

    Parameters:

    ParamTypeRequiredSummary
    ``
    subscriberfunctionYesCallback to execute when the value changes.

    Promise resolution:

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

    Callback parameters:

    ParamTypeRequiredSummary
    ```

    Examples

    JavaScript:

    import { Accessibility } from '@firebolt-js/sdk'
    
    Accessibility.voiceGuidanceSettings((value) => {
      // property value was changed
      console.log(value)
    }).then(listenerId => {
      // you can clear this listener w/ Accessibility.clear(listenerId)
    })
    

    value of value:

    JSON-RPC:

    Request:

    Response:

    {
      "jsonrpc": "2.0",
      "id": "1",
      "result": {
        "listening": "true"
      }
    }
    

    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
    osedCaptionsSettingsclosedCaptionsSettingsListenResponseclosedCaptionsSettings
    iceGuidanceSettingsvoiceGuidanceSettingsListenResponsevoiceGuidanceSettings

    Schemas

    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
    }
    


    Was this article helpful?

    What's Next