Mercurial > hg > ugly-duckling
view src/app/visualisations/cross-hair-inspector.component.ts @ 456:7bb0bac6f8dc
Add export button for recordings and option to remove audio item (also removes all related analyses atm). Revokes associated object url for audio on removal. Will be problematic if the history is used for undo / redo.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Thu, 29 Jun 2017 20:11:14 +0100 |
parents | 95d1f10129a3 |
children | f2bb5ddae867 |
line wrap: on
line source
/** * Created by lucast on 01/06/2017. */ import { AfterViewInit, ChangeDetectionStrategy, Component, ContentChildren, Input, QueryList } from '@angular/core'; import { VerticalValueInspectorRenderer } from './waves-base.component'; import {VerticalScaleComponent} from './vertical-scale.component'; import { RenderLoopService, TaskRemover } from '../services/render-loop/render-loop.service'; import {AudioPlayerService} from '../services/audio-player/audio-player.service'; @Component({ selector: 'ugly-cross-hair-inspector', template: '<ng-content></ng-content>', changeDetection: ChangeDetectionStrategy.OnPush }) export class CrossHairInspectorComponent extends VerticalScaleComponent implements AfterViewInit { @ContentChildren( VerticalValueInspectorRenderer ) inspectorRenderers: QueryList<VerticalValueInspectorRenderer>; @Input() unit: string; @Input() set isAnimated(isAnimated: boolean) { this.mIsAnimated = isAnimated; if (this.removers.length) { this.removers.forEach(remove => remove()); this.removers = []; } if (isAnimated) { this.addTasks(); } } private removers: TaskRemover[]; private mIsAnimated: boolean; constructor(private renderLoop: RenderLoopService, private player: AudioPlayerService) { super(); this.removers = []; } ngAfterViewInit(): void { super.ngAfterViewInit(); this.inspectorRenderers.forEach(renderer => { renderer.renderInspector(this.cachedRange, this.unit); renderer.updatePosition(this.player.getCurrentTime()); }); this.addTasks(); } private addTasks(): void { if (this.inspectorRenderers && this.mIsAnimated) { this.inspectorRenderers.forEach(renderer => { this.removers.push( this.renderLoop.addPlayingTask(renderer.updatePosition) ); }); } } }