summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js')
-rw-r--r--chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js b/chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js
new file mode 100644
index 00000000000..41bc4c8e8d8
--- /dev/null
+++ b/chromium/chrome/browser/resources/chromeos/chromevox/host/chrome/earcons_background.js
@@ -0,0 +1,81 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Earcons library that uses the HTML5 Audio element to play back
+ * auditory cues.
+ *
+ */
+
+
+goog.provide('cvox.EarconsBackground');
+
+goog.require('cvox.AbstractEarcons');
+
+
+/**
+ * @constructor
+ * @extends {cvox.AbstractEarcons}
+ */
+cvox.EarconsBackground = function() {
+ goog.base(this);
+
+ this.audioMap = new Object();
+ if (localStorage['earcons'] === 'false') {
+ this.enabled = false;
+ }
+};
+goog.inherits(cvox.EarconsBackground, cvox.AbstractEarcons);
+
+
+/**
+ * @return {string} The human-readable name of the earcon set.
+ */
+cvox.EarconsBackground.prototype.getName = function() {
+ return 'ChromeVox earcons';
+};
+
+
+/**
+ * @return {string} The base URL for loading earcons.
+ */
+cvox.EarconsBackground.prototype.getBaseUrl = function() {
+ return cvox.EarconsBackground.BASE_URL;
+};
+
+
+/**
+ * @override
+ */
+cvox.EarconsBackground.prototype.playEarcon = function(earcon) {
+ goog.base(this, 'playEarcon', earcon);
+ if (!this.enabled) {
+ return;
+ }
+ if (window['console']) {
+ window['console']['log']('Earcon ' + this.getEarconName(earcon));
+ }
+
+ this.currentAudio = this.audioMap[earcon];
+ if (!this.currentAudio) {
+ this.currentAudio = new Audio(this.getBaseUrl() +
+ this.getEarconFilename(earcon));
+ this.audioMap[earcon] = this.currentAudio;
+ }
+ try {
+ this.currentAudio.currentTime = 0;
+ } catch (e) {
+ }
+ if (this.currentAudio.paused) {
+ this.currentAudio.volume = 0.7;
+ this.currentAudio.play();
+ }
+};
+
+
+/**
+ * The base URL for loading eracons.
+ * @type {string}
+ */
+cvox.EarconsBackground.BASE_URL = 'earcons/';