view src/app/recording-control/recording-control.component.ts @ 394:f45a916eb5b1

Use the cross hair layer for notes, tracks and curve. This involved bodging in unit to ShapedFeatureData, which isn't particularly easy to do because this isn't an encapsulated type. Need to come back to improving this, as I am monkey-patching a unit property onto Arrays etc.
author Lucas Thompson <dev@lucas.im>
date Thu, 01 Jun 2017 18:55:55 +0100
parents 53ea6406d601
children
line wrap: on
line source
/**
 * Created by lucas on 17/03/2017.
 */

import {
  Component,
  OnInit,
  OnDestroy,
  Output,
  EventEmitter
} from '@angular/core';
import {
  AudioRecorderService,
  RecorderServiceStatus
} from '../services/audio-recorder/audio-recorder.service';
import {Subscription} from 'rxjs/Subscription';

@Component({
  selector: 'ugly-recording-control',
  templateUrl: './recording-control.component.html'
})
export class RecordingControlComponent implements OnInit, OnDestroy {
  private recordingState: Subscription;
  private newRecording: Subscription;
  recordingStatus: RecorderServiceStatus;
  @Output() finishedRecording: EventEmitter<Blob>;

  constructor(private recordingService: AudioRecorderService) {
    this.recordingStatus = 'disabled';
    this.finishedRecording = new EventEmitter<Blob>();
  }

  ngOnInit(): void {
    this.recordingState = this.recordingService.recordingStateChange$.subscribe(
      (status: RecorderServiceStatus) => {
        this.recordingStatus = status;
      }
    );
    this.newRecording = this.recordingService.newRecording$.subscribe(
      (recordingBlob: Blob) => {
        this.finishedRecording.emit(recordingBlob);
      }
    );
  }

  ngOnDestroy(): void {
    this.recordingState.unsubscribe();
    this.newRecording.unsubscribe();
  }

   emitToggleRecording() {
     this.recordingService.toggleRecording();
   }
}