import { Howl } from 'howler' ; import { SoundToggler } from './soundtoggler' ; export class SoundPlayer { private soundToggler_ : SoundToggler ; constructor ( soundToggler ) { this . soundToggler_ = soundToggler ; } playMove ( ) { this . play_ ( 'move' , 0.4 ) ; } playCapture ( ) { this . play_ ( 'capture' , 0.4 ) ; } playWrongMove ( ) { this . play_ ( 'wrongmove' , 1 ) ; } playFinishLine ( ) { this . play_ ( 'finishline' , 1 ) ; } private play_ ( soundName , volume ) { if ( ! this . soundToggler_ . areSoundsEnabled ( ) ) { return ; } new Howl ( { src : [ `ogg/${ soundName }.ogg` ] , volume : volume , autoplay : true } ) ; } }