SoundInteractions.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module INSPECTOR {
  2. export interface ISoundInteractions {
  3. setPlaying: (callback: Function) => void;
  4. }
  5. /**
  6. *
  7. */
  8. export class SoundInteractions extends AbstractTreeTool {
  9. private playSound: ISoundInteractions;
  10. private b: boolean;
  11. constructor(playSound: ISoundInteractions) {
  12. super();
  13. this.playSound = playSound;
  14. this.b = false;
  15. this._elem.classList.add('fa-play');
  16. }
  17. protected action() {
  18. super.action();
  19. this._playSound();
  20. }
  21. private _playSound() {
  22. if (this._elem.classList.contains('fa-play')) {
  23. this._elem.classList.remove('fa-play');
  24. this._elem.classList.add('fa-pause');
  25. }
  26. else {
  27. this._elem.classList.remove('fa-pause');
  28. this._elem.classList.add('fa-play');
  29. }
  30. this.playSound.setPlaying(() => {
  31. this._elem.classList.remove('fa-pause');
  32. this._elem.classList.add('fa-play');
  33. });
  34. }
  35. }
  36. }