123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- blocklyApp.AudioService = ng.core
- .Class({
- constructor: [function() {
-
- this.canPlayAudio = false;
- if (ACCESSIBLE_GLOBALS.hasOwnProperty('mediaPathPrefix')) {
- this.canPlayAudio = true;
- var mediaPathPrefix = ACCESSIBLE_GLOBALS['mediaPathPrefix'];
- this.AUDIO_PATHS_ = {
- 'connect': mediaPathPrefix + 'click.mp3',
- 'delete': mediaPathPrefix + 'delete.mp3'
- };
- }
-
- this.cachedAudioFiles_ = {};
- }],
- play_: function(audioId) {
- if (this.canPlayAudio) {
- if (!this.cachedAudioFiles_.hasOwnProperty(audioId)) {
- this.cachedAudioFiles_[audioId] = new Audio(
- this.AUDIO_PATHS_[audioId]);
- }
- this.cachedAudioFiles_[audioId].play();
- }
- },
- playConnectSound: function() {
- this.play_('connect');
- },
- playDeleteSound: function() {
- this.play_('delete');
- }
- });
|