VoiceInteraction API

To use Samsung Product API,

<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>

Should be loaded in index.html

Samsung TVs allow developers to use voice commands such as Navigation, Search, Selection and Media Control to control their application.
The Voice Assistant in the TV can be Bixby or other assistants. Regardless of which assistant is used, the application will interact with it via the Voice Interaction APIs.
For best results, we recommend the application to be implemented with all the features that are described in this document.

Since : 6.0

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Summary of Interfaces and Methods

Interface

Method

VoiceInteractionManagerObject

VoiceInteractionContentContext

VoiceInteractionManager

DOMString getVersion();
void setCallback(VoiceInteractionCallback callback);
void listen();
VoiceInteractionContentContext buildVoiceInteractionContentContextItem(long positionX, long positionY, DOMString title, DOMString[] aliasArr, boolean bFocused);
DOMString buildVoiceInteractionContentContextResponse(VoiceInteractionContentContext[] contentContextArr);

VoiceInteractionCallback

VoiceApplicationState onupdatestate();
boolean onnavigation(VoiceNavigation voiceNavigation);
boolean onplay();
boolean onpause();
boolean onselection(long voiceSelection);
boolean ontitleselection(DOMString title);
boolean onfastforward();
boolean onrewind();
boolean onchangeappstate(VoiceApplicationState state);
boolean onchangeprevioustrack();
boolean onchangenexttrack();
boolean onrestart();
boolean onskipbackward(long offsetSeconds);
boolean onskipforward(long offsetSeconds);
boolean onsetplayposition(long position);
boolean onchangesubtitlemode(MediaFunctionMode mode);
boolean onchangeshufflemode(MediaFunctionMode mode);
boolean onchangescreenfitmode(MediaFunctionMode mode);
boolean onzoom(MediaZoomMode zoom);
boolean onrotate(MediaRotateMode direction);
boolean onchange360mode(MediaFunctionMode mode);
boolean onchangerepeatmode(MediaRepeatMode mode);
DOMString onrequestcontentcontext();
boolean onadditiontolist(ListItem list);
boolean onremovalfromlist(ListItem list);
boolean onplaylist(ListItem list);
boolean onbrowselist(ListItem list);
boolean onskipad();

1. Type Definitions

1.1 VoiceApplicationState

the application status handled via Voice Interaction.

enum VoiceApplicationState {
  "None",
  "Home",
  "List",
  "Player",
  "Setting",
  "Search",
  "Unknown"
};

The following values are supported

  • None : Application Default Status.
  • Home : The status of application's home.
  • List : The status of application showing something in list.
  • Player : The status of application playing something.
  • Setting : The status of application showing its setting.
  • Search : The status of application searching its content.
  • Unknown : The status of unknown.

1.2 VoiceNavigation

The navigation via Voice Interaction.

enum VoiceNavigation {
  "NAV_PREVIOUS",
  "NAV_NEXT",
  "NAV_LEFT",
  "NAV_RIGHT",
  "NAV_UP",
  "NAV_DOWN",
  "NAV_SHOW_MORE",
  "NAV_UNKNOWN"
};

The following values are supported

  • NAV_PREVIOUS : The navigation for the previous page.
  • NAV_NEXT : The navigation for the next page.
  • NAV_LEFT : The navigation for the left item.
  • NAV_RIGHT : The navigation for the right item.
  • NAV_UP : The navigation for the upper item.
  • NAV_DOWN : The navigation for the down item.
  • NAV_SHOW_MORE : The navigation for the detail page.
  • NAV_UNKNOWN : The navigation for unknown.

1.3 MediaFunctionMode

Enum for the parameter of Media Control function mode.

enum MediaFunctionMode {
  "MEDIA_FUNCTION_ON",
  "MEDIA_FUNCTION_OFF"
};

The following values are supported

  • MEDIA_FUNCTION_ON : Media Function Mode On.
  • MEDIA_FUNCTION_OFF : Media Function Mode Off.

1.4 MediaRotateMode

Enum for the parameter of Rotate.

enum MediaRotateMode {
  "MEDIA_ROTATE_LEFT",
  "MEDIA_ROTATE_RIGHT"
};

The following values are supported

  • MEDIA_ROTATE_LEFT : Media Rotate Mode Left.
  • MEDIA_ROTATE_RIGHT : Media Rotate Mode Right.

1.5 MediaZoomMode

Enum for the parameter of Zoom.

enum MediaZoomMode {
  "MEDIA_ZOOM_IN",
  "MEDIA_ZOOM_OUT"
};

The following values are supported

  • MEDIA_ZOOM_IN : Media Zoom Mode In.
  • MEDIA_ZOOM_OUT : Media Zoom Mode Out.

1.6 MediaRepeatMode

Enum for the parameter of Media Repeat.

enum MediaRepeatMode {
  "MEDIA_REPEAT_OFF",
  "MEDIA_REPEAT_ONE",
  "MEDIA_REPEAT_ALL"
};

The following values are supported

  • MEDIA_REPEAT_OFF : Media Repeat Mode Off.
  • MEDIA_REPEAT_ONE : Media Repeat Mode for One track.
  • MEDIA_REPEAT_ALL : Media Repeat Mode for All tracks.

1.7 ListItem

Enum for the parameter of List item.

enum ListItem {
  "LIST_BOOKMARKS",
  "LIST_WATCH_LATER",
  "LIST_PREFERENCE",
  "LIST_SUBSCRIPTION",
  "LIST_UNKNOWN"
};

The following values are supported

  • LIST_BOOKMARKS : Bookmarks
  • LIST_WATCH_LATER : WatchLater
  • LIST_PREFERENCE : Preference
  • LIST_SUBSCRIPTION : Subscription
  • LIST_UNKNOWN : Unknown

2. Interfaces

2.1 VoiceInteractionManagerObject

The VoiceInteractionManagerObject interface defines what is instantiated by the WebAPIs object from the Tizen Platform.
There will be a webapis.voiceinteraction object that allows access to the functionality of the Voice Interaction API.
To use the Voice Interaction API, the following privileges must be declared in the manifest file of the application.
If they are not declared, all usage of these APIs are blocked, and security exceptions are thrown. To use these privileges, the minimum ‘required_version’ is 6.0.

[NoInterfaceObject] interface VoiceInteractionManagerObject {
  readonly attribute VoiceInteractionManager voiceinteraction;
};
WebApi implements VoiceInteractionManagerObject;

Since : 6.0

Attributes

  • readonly VoiceInteractionManager voiceinteraction
    This attribute defines the namespace for voiceinteraction APIs.

2.2 VoiceInteractionContentContext

This interface represents information about the content context for an item.

[NoInterfaceObject] interface VoiceInteractionContentContext {
  attribute long positionX;
  attribute long positionY;
  attribute DOMString title;
  attribute boolean bFocused;
};

Attributes

  • long positionX
    The field for x-axis position of the item.
  • long positionY
    The field for y-axis position of the item.
  • DOMString title
    The field for the title of the item.
  • boolean bFocused
    The field for whether this item has focus.

2.3 VoiceInteractionManager

The VoiceInteractionManager interface is the top-level interface for the VoiceInteractionManager API that provides access to the module functionalities.

[NoInterfaceObject] interface VoiceInteractionManager {
  DOMString getVersion();
  void setCallback(VoiceInteractionCallback callback);
  void listen();
  VoiceInteractionContentContext buildVoiceInteractionContentContextItem(long positionX, long positionY, DOMString title, DOMString[] aliasArr, boolean bFocused);
  DOMString buildVoiceInteractionContentContextResponse(VoiceInteractionContentContext[] contentContextArr);
};

Methods

getVersion

This method gets the plugin's version number.

DOMString getVersion();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • DOMString : DOMString return value of plugin's version.

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if WebAPI is called by a non-TV product.
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 6.0

Code Example :

try {
  var version = webapis.voiceinteraction.getVersion();
  console.log("works with voiceinteraction [" + version + "]");
} catch (e) {
  console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

setCallback

API to define callback functions for the voice interaction commands.

void setCallback(VoiceInteractionCallback callback);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • callback : composing the functions to be called for the voice interaction commands.

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if WebAPI is called by a non-TV product.
    • with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 6.0

Code Example :

try {
  webapis.voiceinteraction.setCallback({
    onupdatestate : function () {
      return "List";
    },
    onnavigation : function (vn) {
      console.log("onnavigation" + vn);
      return true;
    },
    onselection : function (voiceSelection) {
      console.log("Onselection" + voiceSelection);
      return true;
    }
  });
} catch (e) {
  console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

listen

API to start listening the voice interaction commands after setting callbacks by setCallback.

void listen();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if WebAPI is called by a non-TV product.
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 6.0

Code Example :

try {
  webapis.voiceinteraction.listen();
} catch (e) {
  console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
}

buildVoiceInteractionContentContextItem

API to build the VoiceInteractionContentContext of an item.

VoiceInteractionContentContext buildVoiceInteractionContentContextItem(long positionX, long positionY, DOMString title, DOMString[] aliasArr, boolean bFocused);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • positionX : x-axis position of the item.
  • positionY : y-axis position of the item.
  • title : The title of the item.
  • aliasArr : The alias titles of the item.
  • bFocused : Whether this item has a focus.

Return Value :

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if WebAPI is called by a non-TV product.
    • with error type TypeMismatchError, if any input parameters are not compatible with its expected type.
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 6.0

Code Example :

onrequestcontentcontext : function () {
  console.log("onrequestcontentcontext");
  var result = [];
  try {
    var item = webapis.voiceinteraction.buildVoiceInteractionContentContextItem(1,1,"test", ["test set", "test title"], true);
    result.push(item);
  } catch (e) {
    console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
  }
  return webapis.voiceinteraction.buildVoiceInteractionContentContextResponse(result);
}

buildVoiceInteractionContentContextResponse

API to build the response of onrequestcontentcontext callback function from VoiceInteractionContentContext.

DOMString buildVoiceInteractionContentContextResponse(VoiceInteractionContentContext[] contentContextArr);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • contentContextArr : VoiceInteractionContentContext objects of the items showing.

Return Value :

  • DOMString : The DOMString of JsonObject string containing the items showing.

Exceptions :

  • WebAPIException
    • with error type NotSupportedError, if WebAPI is called by a non-TV product.
    • with error type TypeMismatchError, if any input parameters are not compatible with its expected type.
    • with error type SecurityError, if the application does not have the privilege to call this method.

Since : 6.0

Code Example :

onrequestcontentcontext : function () {
  console.log("onrequestcontentcontext");
  var result = [];
  try {
    var item = webapis.voiceinteraction.buildVoiceInteractionContentContextItem(1,1,"test", ["test set", "test title"], true);
    result.push(item);
  } catch (e) {
    console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
  }
  return webapis.voiceinteraction.buildVoiceInteractionContentContextResponse(result);
}

2.4 VoiceInteractionCallback

Every voice interaction application should implement a callback function, so that the Assistant can operate the controls.
Your application can interact with voice assistant by passing the callbacks in webapis.voiceinteraction.setCallback and calling webapis.voiceinteraction.listen.
Except onupdatestate callback, the return value for the callback is the boolean flag for support or not.
If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

[Callback, NoInterfaceObject] interface VoiceInteractionCallback {
  VoiceApplicationState onupdatestate();
  boolean onnavigation(VoiceNavigation voiceNavigation);
  boolean onplay();
  boolean onpause();
  boolean onselection(long voiceSelection);
  boolean ontitleselection(DOMString title);
  boolean onfastforward();
  boolean onrewind();
  boolean onchangeappstate(VoiceApplicationState state);
  boolean onchangeprevioustrack();
  boolean onchangenexttrack();
  boolean onrestart();
  boolean onskipbackward(long offsetSeconds);
  boolean onskipforward(long offsetSeconds);
  boolean onsetplayposition(long position);
  boolean onchangesubtitlemode(MediaFunctionMode mode);
  boolean onchangeshufflemode(MediaFunctionMode mode);
  boolean onchangescreenfitmode(MediaFunctionMode mode);
  boolean onzoom(MediaZoomMode zoom);
  boolean onrotate(MediaRotateMode direction);
  boolean onchange360mode(MediaFunctionMode mode);
  boolean onchangerepeatmode(MediaRepeatMode mode);
  DOMString onrequestcontentcontext();
  boolean onadditiontolist(ListItem list);
  boolean onremovalfromlist(ListItem list);
  boolean onplaylist(ListItem list);
  boolean onbrowselist(ListItem list);
  boolean onskipad();
};

Since : 6.0

Methods

onupdatestate

Developers must specify the current application status to the onupdatestate function to get a proper voice control from the Voice Assistant.
This function is called right before processing every utterance, so that the Voice Assistant can be aware of the application status dynamically.
Depending on the status, the callback function called could be different. Therefore, it is important to return the real status of the application.

VoiceApplicationState onupdatestate();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • VoiceApplicationState : the status of the current application status.
    "None" : Application is in its default status. Same as "Player" status.
    "List" : The application is showing something in list.
    During this status, the utterances "Play this" or "Play" will call onselection(0).
    The utterance "Previous" will call onnavigation ("NAV_PREVIOUS").
    "Player" : The application is playing a piece of content.
    During this status, the utterance "Play this" will call onplay().

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "List";
  }
});

onnavigation

To support navigation controls via voice, the application should have the following callbacks. Otherwise, the Key Event will be generated.

boolean onnavigation(VoiceNavigation voiceNavigation);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • voiceNavigation : The navigation enumeration via Voice.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "List";
  },
  onnavigation : function (voiceNavigation) {
    var bSupport = true;
    console.log("onnavigation : " + voiceNavigation);
    switch(voiceNavigation) {
      case "NAV_PREVIOUS":
      // "Previous page"
      break;
      case "NAV_NEXT":
      // "Next page"
      break;
      case "NAV_LEFT":
      // "Go to left"
      break;
      case "NAV_RIGHT":
      // "Move to right"
      break;
      case "NAV_UP":
      // "Move up"
      break;
      case "NAV_DOWN":
      // "Go down"
      break;
      // If there is no callback implementation for these enums,
      // TV will Generate Remote Control Key Events: "ArrowRight", "ArrowLeft", "ArrowUp", "ArrowDown".
      case "NAV_SHOW_MORE":
      // "Show me more"
      break;
      default:
      bSupport = false;
      break;
    }
    return bSupport;
  }
});

onplay

Supports the media control to handle playback(Play).

boolean onplay();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "Player";
  },
  onplay : function () {
    // TV Default Action: Generates the Remote Control Key, "MediaPlay".
    console.log("OnPlay called");
    return true;
  }
});

onpause

Supports the media control to handle playback(Pause).

boolean onpause();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "Player";
  },
  onpause : function () {
    // TV Default Action: Generates the Remote Control Key, "MediaPlayPause".
    console.log("OnPause called");
    return true;
  }
});

onselection

To support selection controls via voice, the application should have the following callbacks.
This callback supports the ordinal, relative selection control.

boolean onselection(long voiceSelection);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • voiceSelection : The relative index via voice, (ex. the last item is -1, the current item is 0, the first item is 1).

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "List";
  },
  onselection : function (voiceSelection) {
    var bSupport = true;
    console.log("onselection : " + voiceSelection);
    switch(voiceSelection) {
      case -1 :
      // "Select the last one"
      break;
      case 0 :
      // "Select this"
      break;
      default:
      {
        if(voiceSelection >= 1)
        // "Select the first one"
        {
          // Select the (voiceSelection)th item
          // index of the first item is 1
          console.log("For Ordinal : " + voiceSelection);
        }
        else
        {
          bSupport = false;
        }
      }
      break;
    }
    return bSupport;
  }
});

ontitleselection

Title selection refers to an utterance in the format "Select {Title Name}".
To support the title selection via voice, the following two callbacks are required : onrequestcontentcontext and ontitleselection.
The onrequestcontentcontext callback provides the information regarding the content of the screen (such as title and position) to the Samsung TV.
This method will be invoked at the beginning of every utterance. The response consists of positionX(int), positionY(int), title(string), alias(string array) and bFocused(bool).
The title property is used for ASR conversion and the other properties are used to set the priority of each title.
The ontitleselection callback receives the title name from the utterance.

boolean ontitleselection(DOMString title);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • title : the string input via voice.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "List";
  },
  onrequestcontentcontext : function () {
    console.log("onrequestcontentcontext");
    var result = [];
    try {
      var item = {
        "positionX" : 0,
        "positionY" : 0,
        "title" : "Title Text1",
        "alias" : ["Title1", "My Text1"],
        "bFocused" : true
      };
      result.push(item);
      var item2 = {
        "positionX" : 1,
        "positionY" : 0,
        "title" : "Title Text2",
        "alias" : ["Title2", "My Text2"],
        "bFocused" : false
      };
      result.push(item2);
      result.push(webapis.voiceinteraction.buildVoiceInteractionContentContextItem(2,0,"Title Text3", ["Title3", "My Text3"], false));
    } catch (e) {
      console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    return webapis.voiceinteraction.buildVoiceInteractionContentContextResponse(result);
  },
  ontitleselection : function (title) {
    console.log("ontitleselection" + title);
    return true;
  }
});

onfastforward

Supports the media control to handle playback(FF).

boolean onfastforward();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "Player";
  },
  onfastforward : function () {
    // TV Default Action: Generates the Remote Control Key, "MediaFastForward".
    console.log("onfastforward called");
    return true;
  }
});

onrewind

Supports the media control to handle playback(Rewind).

boolean onrewind();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "Player";
  },
  onrewind : function () {
    // TV Default Action: Generates the Remote Control Key, "MediaRewind".
    console.log("onrewind called");
    return true;
  }
});

onchangeappstate

To support the utterance of shortcut commands, the application must have the onchangeappstate callback.

boolean onchangeappstate(VoiceApplicationState state);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • state : The Application Context via Voice.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "None";
  },
  onchangeappstate: function (state) {
    // TV Default Action: Launches the Samsung TV FirstScreen, Menu or Search application. Depending on the input parameter.
    // "Go to Home", "Go to Settings", "Go to Search".
    console.log("onchangeappstate : " + state);
    var bSupport = true;
    switch (state) {
      case "Home":
      // Go to App's Home
      break;
      default:
      bSupport = false;
      break;
    }
    return bSupport;
  }
});

onchangeprevioustrack

In order to handle requests to move to the previous track via voice, the application should override the onchangeprevioustrack callback.

boolean onchangeprevioustrack();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangeprevioustrack : function () {
    console.log("onchangeprevioustrack");
    return true;
  }
});

onchangenexttrack

In order to handle requests to move to the next track via voice, the application should override the onchangenexttrack callback.

boolean onchangenexttrack();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangenexttrack : function () {
    console.log("onchangenexttrack");
    return true;
  }
});

onrestart

In order to handle requests to restart to this track via voice, the application should override the onrestart callback.

boolean onrestart();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onrestart : function () {
    console.log("onrestart");
    return true;
  }
});

onskipbackward

In order to handle requests to skip backward via voice, the application should override the onskipbackward callback.

boolean onskipbackward(long offsetSeconds);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • offsetSeconds : the relative position in seconds.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onskipbackward : function (offsetSeconds) {
    console.log("onskipbackward : " + offsetSeconds);
    return true;
  }
});

onskipforward

In order to handle requests to skip forward via voice, the application should override the onskipforward callback.

boolean onskipforward(long offsetSeconds);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • offsetSeconds : the relative position in seconds.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onskipforward : function (offsetSeconds) {
    console.log("onskipforward : " + offsetSeconds);
    return true;
  }
});

onsetplayposition

In order to handle requests to set play position via voice, the application should override the onsetplayposition callback.

boolean onsetplayposition(long position);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • position : the absolute position in seconds.

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onsetplayposition : function (position) {
    console.log("onsetplayposition : " + position);
    return true;
  }
});

onchangesubtitlemode

In order to handle requests to turn the subtitle feature on/off via voice, the application should override the onchangesubtitlemode callback.

boolean onchangesubtitlemode(MediaFunctionMode mode);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • mode : MEDIA_FUNCTION_ON : Turning On / MEDIA_FUNCTION_OFF : Turning Off

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangesubtitlemode : function (mode) {
    console.log("onchangesubtitlemode");
    switch(mode) {
      case "MEDIA_FUNCTION_ON" :
      console.log("Function ON");
      break;
      default :
      console.log("Function OFF");
      break;
    }
    return true;
  }
});

onchangeshufflemode

In order to handle requests to turn the shuffle feature on/off via voice, the application should override the onchangeshufflemode callback.

boolean onchangeshufflemode(MediaFunctionMode mode);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • mode : MEDIA_FUNCTION_ON : Turning On / MEDIA_FUNCTION_OFF : Turning Off

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangeshufflemode : function (mode) {
    console.log("onchangeshufflemode");
    switch(mode) {
      case "MEDIA_FUNCTION_ON" :
      console.log("Function ON");
      break;
      default :
      console.log("Function OFF");
      break;
    }
    return true;
  }
});

onchangescreenfitmode

In order to handle requests to turn the screen fit feature on/off via voice, the application should override the onchangescreenfitmode callback.

boolean onchangescreenfitmode(MediaFunctionMode mode);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • mode : MEDIA_FUNCTION_ON : Turning On / MEDIA_FUNCTION_OFF : Turning Off

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangescreenfitmode : function (mode) {
    console.log("onchangescreenfitmode");
    switch(mode) {
      case "MEDIA_FUNCTION_ON" :
      console.log("Function ON");
      break;
      default :
      console.log("Function OFF");
      break;
    }
    return true;
  }
});

onzoom

In order to handle requests to zoom in/out via voice, the application should override the onzoom callback.

boolean onzoom(MediaZoomMode zoom);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • zoom : MEDIA_ZOOM_IN : zoom in / MEDIA_ZOOM_OUT : zoom out

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onzoom : function (zoom) {
    console.log("onzoom");
    switch(zoom) {
      case "MEDIA_ZOOM_IN" :
      console.log("Zoom IN");
      break;
      default :
      console.log("Zoom OUT");
      break;
    }
    return true;
  }
});

onrotate

In order to handle requests to rotate left/right via voice, the application should override the onrotate callback.

boolean onrotate(MediaRotateMode direction);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • direction : MEDIA_ROTATE_LEFT : rotate left / MEDIA_ROTATE_RIGHT : rotate right

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onrotate : function (direction) {
    console.log("onrotate");
    switch(direction) {
      case "MEDIA_ROTATE_LEFT" :
      console.log("Rotate Left");
      break;
      default :
      console.log("Rotate Right");
      break;
    }
    return true;
  }
});

onchange360mode

In order to handle requests to turn the 360 feature on/off via voice, the application should override the onchange360mode callback.

boolean onchange360mode(MediaFunctionMode mode);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • mode : MEDIA_FUNCTION_ON : Turning On / MEDIA_FUNCTION_OFF : Turning Off

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchange360mode : function (mode) {
    console.log("onchange360mode");
    switch(mode) {
      case "MEDIA_FUNCTION_ON" :
      console.log("Function ON");
      break;
      default :
      console.log("Function OFF");
      break;
    }
    return true;
  }
});

onchangerepeatmode

In order to handle requests to change the repeat mode via voice, the application should override the onchangerepeatmode callback.

boolean onchangerepeatmode(MediaRepeatMode mode);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • mode : MEDIA_REPEAT_OFF : repeat mode off / MEDIA_REPEAT_ONE : repeat this track / MEDIA_REPEAT_ALL : repeat all tracks

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung device may perform its basic function.

Since : 6.0

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onchangerepeatmode : function (mode) {
    console.log("onchangerepeatmode");
    switch(mode) {
      case "MEDIA_REPEAT_ONE" :
      console.log("ONE");
      break;
      case "MEDIA_REPEAT_ALL" :
      console.log("ALL");
      break;
      default :
      console.log("OFF");
      break;
    }
    return true;
  }
});

onrequestcontentcontext

In order to support the voice title selection via voice, the application should override the onrequestcontentcontext callback, return the JsonObject string for the current content context list showing.

DOMString onrequestcontentcontext();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • DOMString : DOMString containing JsonObject string for the content context list.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    console.log("Assistant tries to get app state");
    return "List";
  },
  onrequestcontentcontext : function () {
    console.log("onrequestcontentcontext ");
    var result = [];
    try {
      var item = webapis.voiceinteraction.buildVoiceInteractionContentContextItem(1,1,"test", ["test set", "test title"], true);
      result.push(item);
      var item2 = webapis.voiceinteraction.buildVoiceInteractionContentContextItem(2,1,"test2", ["test set 2", "test title 2"], false);
      result.push(item2);
    } catch (e) {
      console.log("exception [" + e.code + "] name: " + e.name + " message: " + e.message);
    }
    return webapis.voiceinteraction.buildVoiceInteractionContentContextResponse(result);
  }
});

onadditiontolist

In order to handle requests to add this context to list via voice, the application should override the onadditiontolist callback.

boolean onadditiontolist(ListItem list);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • list : LIST_BOOKMARKS : bookmarks / LIST_WATCH_LATER : watch later / LIST_PREFERENCE : preference / LIST_SUBSCRIPTION : subscription

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung TV may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onadditiontolist : function (list) {
    console.log("onadditiontolist");
    switch(list) {
      case "LIST_BOOKMARKS" :
      console.log("Add this context to Bookmarks");
      break;
      case "LIST_WATCH_LATER" :
      console.log("Add this context to Watch later");
      break;
      case "LIST_PREFERENCE" :
      console.log("Like this context");
      break;
      case "LIST_SUBSCRIPTION" :
      console.log("Subscribe to context");
      break;
      default :
      break;
    }
    return true;
  }
});

onremovalfromlist

In order to handle requests to remove this context from list via voice, the application should override the onremovalfromlist callback.

boolean onremovalfromlist(ListItem list);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • list : LIST_BOOKMARKS : bookmarks / LIST_WATCH_LATER : watch later / LIST_PREFERENCE : preference / LIST_SUBSCRIPTION : subscription

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung TV may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onremovalfromlist : function (list) {
    console.log("onremovalfromlist");
    switch(list) {
      case "LIST_BOOKMARKS" :
      console.log("Remove this context from Bookmarks");
      break;
      case "LIST_WATCH_LATER" :
      console.log("Remove this context from Watch later");
      break;
      case "LIST_PREFERENCE" :
      console.log("Dislike this context");
      break;
      case "LIST_SUBSCRIPTION" :
      console.log("Unsubscribe from this context");
      break;
      default :
      break;
    }
    return true;
  }
});

onplaylist

In order to handle requests to play this context from list via voice, the application should override the onplaylist callback.
NOTE: This feature is only available for 25Y TV models at the moment.

boolean onplaylist(ListItem list);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • list : LIST_PREFERENCE : preference / LIST_SUBSCRIPTION : subscription / LIST_WATCH_LATER : watch later

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung TV may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onplaylist : function (list) {
    console.log("onplaylist");
    switch(list) {
      case "LIST_PREFERENCE" :
      console.log("Play liked content");
      break;
      case "LIST_SUBSCRIPTION" :
      console.log("Play subscription content");
      break;
      case "LIST_WATCH_LATER" :
      console.log("Play watch later content");
      break;
      default :
      break;
    }
    return true;
  }
});

onbrowselist

In order to handle requests to browse this context from list via voice, the application should override the onbrowselist callback.
NOTE: This feature is only available for 25Y TV models at the moment.

boolean onbrowselist(ListItem list);

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Parameters :

  • list : LIST_PREFERENCE : preference / LIST_SUBSCRIPTION : subscription / LIST_WATCH_LATER : watch later

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung TV may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "List";
  },
  onbrowselist : function (list) {
    console.log("onbrowselist");
    switch(list) {
      case "LIST_PREFERENCE" :
      console.log("Browse liked content");
      break;
      case "LIST_SUBSCRIPTION" :
      console.log("Browse subscription content");
      break;
      case "LIST_WATCH_LATER" :
      console.log("Browse watch later content");
      break;
      default :
      break;
    }
    return true;
  }
});

onskipad

In order to handle requests to skip ad content via voice, the application should override the onskipad callback.
NOTE: This feature is only available for 25Y TV models at the moment.

boolean onskipad();

Product : TV

Privilege Level : Public

Privilege : http://developer.samsung.com/privilege/voicecontrol

Return Value :

  • boolean : boolean value of whether the app supports this feature.
    If a callback returns the false/undefined value, or there is no callback implementation for the utterance, Samsung TV may perform its basic function.

Since : 6.5

Code Example :

webapis.voiceinteraction.setCallback({
  onupdatestate : function () {
    return "Player";
  },
  onskipad : function () {
    console.log("onskipad");
    return true;
  }
});

3. Full WebIDL

module VoiceInteraction {
  enum VoiceApplicationState {
    "None",
    "Home",
    "List",
    "Player",
    "Setting",
    "Search",
    "Unknown"
  };

  enum VoiceNavigation {
    "NAV_PREVIOUS",
    "NAV_NEXT",
    "NAV_LEFT",
    "NAV_RIGHT",
    "NAV_UP",
    "NAV_DOWN",
    "NAV_SHOW_MORE",
    "NAV_UNKNOWN"
  };

  enum MediaFunctionMode {
    "MEDIA_FUNCTION_ON",
    "MEDIA_FUNCTION_OFF"
  };

  enum MediaRotateMode {
    "MEDIA_ROTATE_LEFT",
    "MEDIA_ROTATE_RIGHT"
  };

  enum MediaZoomMode {
    "MEDIA_ZOOM_IN",
    "MEDIA_ZOOM_OUT"
  };

  enum MediaRepeatMode {
    "MEDIA_REPEAT_OFF",
    "MEDIA_REPEAT_ONE",
    "MEDIA_REPEAT_ALL"
  };

  enum ListItem {
    "LIST_BOOKMARKS",
    "LIST_WATCH_LATER",
    "LIST_PREFERENCE",
    "LIST_SUBSCRIPTION",
    "LIST_UNKNOWN"
  };

  [NoInterfaceObject] interface VoiceInteractionManagerObject {
    readonly attribute VoiceInteractionManager voiceinteraction;
  };

  WebApi implements VoiceInteractionManagerObject;

  [NoInterfaceObject] interface VoiceInteractionContentContext {
    attribute long positionX;
    attribute long positionY;
    attribute DOMString title;
    attribute boolean bFocused;
  };

  [NoInterfaceObject] interface VoiceInteractionManager {
    DOMString getVersion();
    void setCallback(VoiceInteractionCallback callback);
    void listen();
    VoiceInteractionContentContext buildVoiceInteractionContentContextItem(long positionX, long positionY, DOMString title, DOMString[] aliasArr, boolean bFocused);
    DOMString buildVoiceInteractionContentContextResponse(VoiceInteractionContentContext[] contentContextArr);
  };

  [Callback, NoInterfaceObject] interface VoiceInteractionCallback {
    VoiceApplicationState onupdatestate();
    boolean onnavigation(VoiceNavigation voiceNavigation);
    boolean onplay();
    boolean onpause();
    boolean onselection(long voiceSelection);
    boolean ontitleselection(DOMString title);
    boolean onfastforward();
    boolean onrewind();
    boolean onchangeappstate(VoiceApplicationState state);
    boolean onchangeprevioustrack();
    boolean onchangenexttrack();
    boolean onrestart();
    boolean onskipbackward(long offsetSeconds);
    boolean onskipforward(long offsetSeconds);
    boolean onsetplayposition(long position);
    boolean onchangesubtitlemode(MediaFunctionMode mode);
    boolean onchangeshufflemode(MediaFunctionMode mode);
    boolean onchangescreenfitmode(MediaFunctionMode mode);
    boolean onzoom(MediaZoomMode zoom);
    boolean onrotate(MediaRotateMode direction);
    boolean onchange360mode(MediaFunctionMode mode);
    boolean onchangerepeatmode(MediaRepeatMode mode);
    DOMString onrequestcontentcontext();
    boolean onadditiontolist(ListItem list);
    boolean onremovalfromlist(ListItem list);
    boolean onplaylist(ListItem list);
    boolean onbrowselist(ListItem list);
    boolean onskipad();
  };

};