@enact/webos
Advanced tools
Comparing version 2.0.0-beta.5 to 2.0.0-beta.6
@@ -5,2 +5,8 @@ # Change Log | ||
## [2.0.0-beta.6] - 2018-06-04 | ||
### Fixed | ||
- `webos/speech` method `readAlert` to subscribe to changes in audio guidance to improve speech response time | ||
## [2.0.0-beta.5] - 2018-05-29 | ||
@@ -7,0 +13,0 @@ |
{ | ||
"name": "@enact/webos", | ||
"version": "2.0.0-beta.5", | ||
"version": "2.0.0-beta.6", | ||
"description": "webOS support library", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@enact/core": "^2.0.0-beta.5", | ||
"@enact/core": "^2.0.0-beta.6", | ||
"prop-types": "^15.6.0", | ||
@@ -32,0 +32,0 @@ "react": "^16.2.0", |
@@ -17,20 +17,11 @@ "use strict"; | ||
/* global console */ | ||
var audioGuidanceEnabled = null; | ||
/** | ||
* Read alert text when accessibility VoiceReadout enabled. | ||
* | ||
* @function | ||
* @param {String} string String to voice readout. | ||
* @param {Boolean} [clear=true] Clear option for TTS. If true, it will cut off previous reading. | ||
* @returns {undefined} | ||
* @memberof webos/speech | ||
*/ | ||
var readAlert = function readAlert(string) { | ||
var clear = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (_platform.platform.tv) { | ||
var checkAudioGuidance = function checkAudioGuidance(callback) { | ||
return new _LS2Request.default().send({ | ||
var checkAudioGuidance = function checkAudioGuidance() { | ||
return new Promise(function (resolve, reject) { | ||
if (audioGuidanceEnabled === null) { | ||
new _LS2Request.default().send({ | ||
service: 'luna://com.webos.settingsservice', | ||
method: 'getSystemSettings', | ||
subscribe: true, | ||
parameters: { | ||
@@ -42,13 +33,26 @@ 'keys': ['audioGuidance'], | ||
if (res && res.settings.audioGuidance === 'on') { | ||
callback(); | ||
audioGuidanceEnabled = true; | ||
resolve(); | ||
return; | ||
} | ||
audioGuidanceEnabled = false; | ||
reject(); | ||
}, | ||
onFailure: function onFailure(err) { | ||
console.error('Failed to get system AudioGuidance settings: ' + JSON.stringify(err)); | ||
reject('Failed to get system AudioGuidance settings: ' + JSON.stringify(err)); | ||
} | ||
}); | ||
}; | ||
} else if (audioGuidanceEnabled) { | ||
resolve(); | ||
} else { | ||
reject(); | ||
} | ||
}); | ||
}; | ||
var readAlertMessage = function readAlertMessage() { | ||
return new _LS2Request.default().send({ | ||
var readAlertMessage = function readAlertMessage(string, clear) { | ||
return function () { | ||
return new Promise(function (resolve, reject) { | ||
new _LS2Request.default().send({ | ||
service: 'luna://com.webos.service.tts', | ||
@@ -60,9 +64,30 @@ method: 'speak', | ||
}, | ||
onSuccess: resolve, | ||
onFailure: function onFailure(err) { | ||
console.error('Failed to readAlertMessage: ' + JSON.stringify(err)); | ||
reject('Failed to readAlertMessage: ' + JSON.stringify(err)); | ||
} | ||
}); | ||
}; | ||
}); | ||
}; | ||
}; | ||
/** | ||
* Read alert text when accessibility VoiceReadout enabled. | ||
* | ||
* @function | ||
* @param {String} string String to voice readout. | ||
* @param {Boolean} [clear=true] Clear option for TTS. If true, it will cut off previous reading. | ||
* @returns {undefined} | ||
* @memberof webos/speech | ||
*/ | ||
checkAudioGuidance(readAlertMessage); | ||
var readAlert = function readAlert(string) { | ||
var clear = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
if (_platform.platform.tv) { | ||
checkAudioGuidance().then(readAlertMessage(string, clear)).catch(function (message) { | ||
if (message) { | ||
console.error("Failed to readAlert: ".concat(message)); | ||
} | ||
}); | ||
} else { | ||
@@ -69,0 +94,0 @@ console.warn('Platform doesn\'t support TTS api.'); |
42495
880
Updated@enact/core@^2.0.0-beta.6