The Contact control interface can be used to control the state of the output contacts (VP330 / EVP380) and to retrieve the state of the input contacts.
The following API is asynchronous and using Promise.
To use this API, you first need to get the contact control interface thanks to IDAL.getControlInterfaces().
Methods
getInputByName(name) → {Promise.<Contact~InputContactInfo>|Promise.<ErrorStatus>}
Get the current state of the input contacts.
Input contacts are identified by a name:
- "standalone" for the single contact available on all players.
- "combined" for the 8 input contacts available on VP330 and EVP380.
You can also retrieve the contact states in real time thanks to the InputContactEvent event.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Input contact name ("standalone" or "combined"). |
Returns:
-
A promise resolved with an InputContactInfo.
- Type
- Promise.<Contact~InputContactInfo>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
setInputConfiguration(config) → {Promise.<boolean>|Promise.<ErrorStatus>}
Set the input contacts configuration (control mode).
Input contact combinations are binded to actions ("play folder" by default)
which are automatically managed by the video playback engine.
If you need to override this behavior and control the input contacts from the
HTML/JavaScript layer, you have to call this method with config.controller
set to 'browser'
.
The configuration can be automatically reverted to the default depending on the value of config.lifetime
.
This method can also be used to map input contact events to regular keyboard events. It makes it possible to use input contacts as a keyboard and use generic key event handlers such as keyup and keydown.
Example
Usage of input contacts to keyboard events mapping.
// In this example, 'contact' is the variable referencing the contact control interface..
// Configuring input contacts to act as arrows, enter and escape keys...
// The configuration will be reverted when a new page is loaded.
var config = {
controller: "browser",
lifetime: "url",
keymaps: {
combined: [
"ArrowLeft",
"ArrowRight",
"ArrowUp",
"ArrowDown",
"Enter",
"Escape"
]
}
};
contact.setInputConfiguration(config)
.then(function(e) {
// Do what you need here
})
.catch(function(e) {
// Handle error here
});
// Install keyboard event handler
window.addEventListener("keydown", function(e) {
console.log("Key down: key=" + e.key + ", code=" + e.code + ", keyCode=" + e.keyCode);
});
Parameters:
Name | Type | Description |
---|---|---|
config |
Contact~InputContactConfig | The configuration to apply to input contacts. |
Returns:
-
A promise resolved with a
boolean
value.- Type
- Promise.<boolean>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
setOutputById(id, value) → {Promise.<boolean>|Promise.<ErrorStatus>}
Set a single output contact state using its identifier.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | The contact identifier is a value between 0 and 7. |
value |
number | boolean | The new contact state:
|
Returns:
-
A promise resolved with a
boolean
value.- Type
- Promise.<boolean>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
setOutputByMask(value, mask) → {Promise.<boolean>|Promise.<ErrorStatus>}
Set many output contacts at once.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The bitmask of all the output contact values. |
mask |
number | The bitmask of the contacts to actually set. |
Returns:
-
A promise resolved with a
boolean
value.- Type
- Promise.<boolean>
-
A promise rejected with an ErrorStatus.
- Type
- Promise.<ErrorStatus>
Type Definitions
InputContactConfig
Configuration to set on input contacts.
It defines the entity responsible for managing the input contacts: the browser or the video player.
It is also possible to configure the input contact keyboard mapping.
Properties:
Name | Type | Attributes | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
controller |
'browser' | 'videoplayer' | The name of input contact controller. |
||||||||||||||
lifetime |
'url' | 'site' | 'session' | 'scenario' |
<optional> |
'url'
|
The configuration lifetime can be set when the controller is the web browser.
|
||||||||||||
keymaps |
Object |
<optional> |
Can only be used when controller is set to Properties
|
List of available key codes
Hover the mouse over the keys to see their names.
InputContactInfo
A InputContactInfo contains the states of one or more input contacts.
Properties:
Name | Type | Description |
---|---|---|
name |
string | The logical name of the input contact group. |
values |
Array.<boolean> | An array of input contact values. |
Events
InputContactEvent
InputContactEvent are fired when the state of the input contacts is modified.
Properties:
Name | Type | Description |
---|---|---|
type |
'idal-contact-event' | The custom event type. |
detail |
Contact~InputContactInfo | The state of the input contacts. |
This event shall be registered using window.addEventListener() as defined by the DOM specification.
Type:
Example
window.addEventListener('idal-contact-event', function(e) {
var info = e.detail;
console.log("Input contact name: " + info.name);
for (var i = 0 ; i < info.values.length ; i++) {
console.log("Contact " + i + ": " + info.values[i]);
}
});