1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * @fileoverview Earcons library that uses the HTML5 Audio element to play back
12 goog.provide('cvox.EarconsBackground');
14 goog.require('cvox.AbstractEarcons');
19 * @extends {cvox.AbstractEarcons}
21 cvox.EarconsBackground = function() {
24 this.audioMap = new Object();
25 if (localStorage['earcons'] === 'false') {
29 goog.inherits(cvox.EarconsBackground, cvox.AbstractEarcons);
33 * @return {string} The human-readable name of the earcon set.
35 cvox.EarconsBackground.prototype.getName = function() {
36 return 'ChromeVox earcons';
41 * @return {string} The base URL for loading earcons.
43 cvox.EarconsBackground.prototype.getBaseUrl = function() {
44 return cvox.EarconsBackground.BASE_URL;
51 cvox.EarconsBackground.prototype.playEarcon = function(earcon) {
52 goog.base(this, 'playEarcon', earcon);
56 if (window['console']) {
57 window['console']['log']('Earcon ' + this.getEarconName(earcon));
60 this.currentAudio = this.audioMap[earcon];
61 if (!this.currentAudio) {
62 this.currentAudio = new Audio(chrome.extension.getURL(this.getBaseUrl() +
63 this.getEarconFilename(earcon)));
64 this.audioMap[earcon] = this.currentAudio;
67 this.currentAudio.currentTime = 0;
70 if (this.currentAudio.paused) {
71 this.currentAudio.volume = 0.7;
72 this.currentAudio.play();
78 * The base URL for loading eracons.
81 cvox.EarconsBackground.BASE_URL = 'chromevox/background/earcons/';