OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview This is the low-level class that generates ChromeVox's | 6 * @fileoverview This is the low-level class that generates ChromeVox's |
7 * earcons. It's designed to be self-contained and not depend on the | 7 * earcons. It's designed to be self-contained and not depend on the |
8 * rest of the code. | 8 * rest of the code. |
9 */ | 9 */ |
10 | 10 |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 removeCount++; | 678 removeCount++; |
679 } | 679 } |
680 this.progressSources_.splice(0, removeCount); | 680 this.progressSources_.splice(0, removeCount); |
681 }; | 681 }; |
682 | 682 |
683 /** | 683 /** |
684 * Start playing tick / tock progress sounds continuously until | 684 * Start playing tick / tock progress sounds continuously until |
685 * explicitly canceled. | 685 * explicitly canceled. |
686 */ | 686 */ |
687 EarconEngine.prototype.startProgress = function() { | 687 EarconEngine.prototype.startProgress = function() { |
| 688 if (this.progressIntervalID_) { |
| 689 this.cancelProgress(); |
| 690 } |
| 691 |
688 this.progressSources_ = []; | 692 this.progressSources_ = []; |
689 this.progressGain_ = 0.5; | 693 this.progressGain_ = 0.5; |
690 this.progressTime_ = this.context_.currentTime; | 694 this.progressTime_ = this.context_.currentTime; |
691 this.generateProgressTickTocks_(); | 695 this.generateProgressTickTocks_(); |
692 this.progressIntervalID_ = window.setInterval( | 696 this.progressIntervalID_ = window.setInterval( |
693 this.generateProgressTickTocks_.bind(this), 1000); | 697 this.generateProgressTickTocks_.bind(this), 1000); |
694 }; | 698 }; |
695 | 699 |
696 /** | 700 /** |
697 * Stop playing any tick / tock progress sounds. | 701 * Stop playing any tick / tock progress sounds. |
698 */ | 702 */ |
699 EarconEngine.prototype.cancelProgress = function() { | 703 EarconEngine.prototype.cancelProgress = function() { |
700 if (!this.progressIntervalID_) { | 704 if (!this.progressIntervalID_) { |
701 return; | 705 return; |
702 } | 706 } |
703 | 707 |
704 for (var i = 0; i < this.progressSources_.length; i++) { | 708 for (var i = 0; i < this.progressSources_.length; i++) { |
705 this.progressSources_[i][1].stop(); | 709 this.progressSources_[i][1].stop(); |
706 } | 710 } |
707 this.progressSources_ = []; | 711 this.progressSources_ = []; |
708 | 712 |
709 window.clearInterval(this.progressIntervalID_); | 713 window.clearInterval(this.progressIntervalID_); |
710 this.progressIntervalID_ = null; | 714 this.progressIntervalID_ = null; |
711 }; | 715 }; |
OLD | NEW |