Skip to content

Commit

Permalink
workaround for updating progress bar in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
hwellmann committed Oct 14, 2023
1 parent b30cbeb commit 451cb9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/component/record/record.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 class="mat-h2">Recognize</h2>

<div id="progress" >
<mat-progress-bar mode="determinate" [value]="progress"></mat-progress-bar>
<mat-progress-bar mode="determinate" [value]="progressbarValue"></mat-progress-bar>
</div>

<div id="button-container">
Expand Down
21 changes: 17 additions & 4 deletions src/app/component/record/record.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { interval } from 'rxjs';
import { Recorder } from 'src/app/service/transcription/recorder';

@Component({
Expand All @@ -9,17 +10,18 @@ import { Recorder } from 'src/app/service/transcription/recorder';
export class RecordComponent {

progress: number;
progressbarValue: number;

constructor(
private router: Router,
private recorder: Recorder) {

this.recorder.progress.subscribe(progress =>
this.progress = progress
);
// using this.progress directly in mat-progress-bar does not work in Firefox
this.recorder.progress.subscribe(progress => this.progress = progress);

this.recorder.transcriptionResult.subscribe(transcription => {
this.progress = 0;
this.progressbarValue = 0;
if (!transcription) {
return;
}
Expand All @@ -28,7 +30,18 @@ export class RecordComponent {
});
}

async startRecording(): Promise<void> {

async startRecording() {
const timer = interval(100);

const sub = timer.subscribe((sec) => {
this.progressbarValue = this.progress;

if (this.progressbarValue >= 100) {
sub.unsubscribe();
}
});

await this.recorder.initAudio();
this.recorder.start();
}
Expand Down

0 comments on commit 451cb9f

Please sign in to comment.