Is there a way to create a custom function in my component.ts file to pause an HTML audio element? I can't seem to find any built-in methods for pausing audio when using document.getElement.
<audio controls id="audio-file" >
<source src="sample.wav" type="audio/wav">
</audio>
import { Component, OnInit, Inject } from '@angular/core';
import { DOCUMENT } from "@angular/platform-browser";
import { WINDOW } from "../../services/window.service";
@Component({
selector: 'app-audio',
templateUrl: './audio.component.html',
styleUrls: ['./audio.component.css']
})
export class AudioComponent implements OnInit {
private audio = this.document.getElementById("audio-file")
constructor(
@Inject(DOCUMENT) private document: Document,
@Inject(WINDOW) private window: Window
) { }
ngOnInit() {
}
stopAudio(){
this.document.getElementById('audio-file')
}
}