mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification.
This commit is contained in:
@@ -29,8 +29,10 @@ blocklyApp.AppComponent = ng.core.Component({
|
|||||||
template: `
|
template: `
|
||||||
<blockly-workspace></blockly-workspace>
|
<blockly-workspace></blockly-workspace>
|
||||||
<blockly-sidebar></blockly-sidebar>
|
<blockly-sidebar></blockly-sidebar>
|
||||||
<div *ngIf="getAriaLiveReadout()" class="blocklyAriaLiveStatus"
|
<!-- Warning: Hiding this when there is no content looks visually nicer,
|
||||||
aria-hidden="true">
|
but it can have unexpected side effects. In particular, it sometimes stops
|
||||||
|
screenreaders from reading anything in this div. -->
|
||||||
|
<div class="blocklyAriaLiveStatus">
|
||||||
<span aria-live="polite" role="status">{{getAriaLiveReadout()}}</span>
|
<span aria-live="polite" role="status">{{getAriaLiveReadout()}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -23,27 +23,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
blocklyApp.AudioService = ng.core.Class({
|
blocklyApp.AudioService = ng.core.Class({
|
||||||
constructor: [function() {
|
constructor: [
|
||||||
// We do not play any audio unless a media path prefix is specified.
|
blocklyApp.NotificationsService, function(notificationsService) {
|
||||||
this.canPlayAudio = false;
|
this.notificationsService = notificationsService;
|
||||||
|
|
||||||
if (ACCESSIBLE_GLOBALS.hasOwnProperty('mediaPathPrefix')) {
|
// We do not play any audio unless a media path prefix is specified.
|
||||||
this.canPlayAudio = true;
|
this.canPlayAudio = false;
|
||||||
var mediaPathPrefix = ACCESSIBLE_GLOBALS['mediaPathPrefix'];
|
|
||||||
this.AUDIO_PATHS_ = {
|
if (ACCESSIBLE_GLOBALS.hasOwnProperty('mediaPathPrefix')) {
|
||||||
'connect': mediaPathPrefix + 'click.mp3',
|
this.canPlayAudio = true;
|
||||||
'delete': mediaPathPrefix + 'delete.mp3',
|
var mediaPathPrefix = ACCESSIBLE_GLOBALS['mediaPathPrefix'];
|
||||||
'oops': mediaPathPrefix + 'oops.mp3'
|
this.AUDIO_PATHS_ = {
|
||||||
};
|
'connect': mediaPathPrefix + 'click.mp3',
|
||||||
|
'delete': mediaPathPrefix + 'delete.mp3',
|
||||||
|
'oops': mediaPathPrefix + 'oops.mp3'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cachedAudioFiles_ = {};
|
||||||
}
|
}
|
||||||
|
],
|
||||||
this.cachedAudioFiles_ = {};
|
play_: function(audioId, onEndedCallback) {
|
||||||
}],
|
|
||||||
play_: function(audioId) {
|
|
||||||
if (this.canPlayAudio) {
|
if (this.canPlayAudio) {
|
||||||
if (!this.cachedAudioFiles_.hasOwnProperty(audioId)) {
|
if (!this.cachedAudioFiles_.hasOwnProperty(audioId)) {
|
||||||
this.cachedAudioFiles_[audioId] = new Audio(this.AUDIO_PATHS_[audioId]);
|
this.cachedAudioFiles_[audioId] = new Audio(this.AUDIO_PATHS_[audioId]);
|
||||||
}
|
}
|
||||||
|
if (onEndedCallback) {
|
||||||
|
this.cachedAudioFiles_[audioId].addEventListener(
|
||||||
|
'ended', onEndedCallback);
|
||||||
|
} else {
|
||||||
|
this.cachedAudioFiles_[audioId].removeEventListener('ended');
|
||||||
|
}
|
||||||
|
|
||||||
this.cachedAudioFiles_[audioId].play();
|
this.cachedAudioFiles_[audioId].play();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -53,7 +64,14 @@ blocklyApp.AudioService = ng.core.Class({
|
|||||||
playDeleteSound: function() {
|
playDeleteSound: function() {
|
||||||
this.play_('delete');
|
this.play_('delete');
|
||||||
},
|
},
|
||||||
playOopsSound: function() {
|
playOopsSound: function(optionalStatusMessage) {
|
||||||
this.play_('oops');
|
if (optionalStatusMessage) {
|
||||||
|
var that = this;
|
||||||
|
this.play_('oops', function() {
|
||||||
|
that.notificationsService.speak(optionalStatusMessage);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.play_('oops');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,6 +53,6 @@ blocklyApp.NotificationsService = ng.core.Class({
|
|||||||
}, 20));
|
}, 20));
|
||||||
this.timeouts.push(setTimeout(function() {
|
this.timeouts.push(setTimeout(function() {
|
||||||
that.setDisplayedMessage_('');
|
that.setDisplayedMessage_('');
|
||||||
}, 2000));
|
}, 5000));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -493,8 +493,7 @@ blocklyApp.TreeService = ng.core.Class({
|
|||||||
if (this.getParentListElement_(activeDesc)) {
|
if (this.getParentListElement_(activeDesc)) {
|
||||||
statusMessage += ' Press left to go to parent list.';
|
statusMessage += ' Press left to go to parent list.';
|
||||||
}
|
}
|
||||||
this.audioService.playOopsSound();
|
this.audioService.playOopsSound(statusMessage);
|
||||||
this.notificationsService.speak(statusMessage);
|
|
||||||
}
|
}
|
||||||
} else if (e.keyCode == 39) {
|
} else if (e.keyCode == 39) {
|
||||||
// Right arrow key. Go down a level, if possible.
|
// Right arrow key. Go down a level, if possible.
|
||||||
@@ -505,8 +504,7 @@ blocklyApp.TreeService = ng.core.Class({
|
|||||||
if (nextSibling) {
|
if (nextSibling) {
|
||||||
this.setActiveDesc(nextSibling.id, treeId);
|
this.setActiveDesc(nextSibling.id, treeId);
|
||||||
} else {
|
} else {
|
||||||
this.audioService.playOopsSound();
|
this.audioService.playOopsSound('Reached bottom of list.');
|
||||||
this.notificationsService.speak('Reached bottom of list.');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
<script src="../../accessible/libs/angular2-all.umd.min.js"></script>
|
<script src="../../accessible/libs/angular2-all.umd.min.js"></script>
|
||||||
|
|
||||||
<script src="../../accessible/utils.service.js"></script>
|
<script src="../../accessible/utils.service.js"></script>
|
||||||
<script src="../../accessible/audio.service.js"></script>
|
|
||||||
<script src="../../accessible/notifications.service.js"></script>
|
<script src="../../accessible/notifications.service.js"></script>
|
||||||
|
<script src="../../accessible/audio.service.js"></script>
|
||||||
<script src="../../accessible/block-connection.service.js"></script>
|
<script src="../../accessible/block-connection.service.js"></script>
|
||||||
<script src="../../accessible/block-options-modal.service.js"></script>
|
<script src="../../accessible/block-options-modal.service.js"></script>
|
||||||
<script src="../../accessible/keyboard-input.service.js"></script>
|
<script src="../../accessible/keyboard-input.service.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user