I have an audio tag in my template and I want to access these methods inside my component, cause I need functions for play and pause according to click events.
I tried the way below, but I can't access play() method. What is the correct approach?
TEMPLATE:
<div align="center" class="tela">
<div class="telaPlay" *ngIf="showPlay">
<p>
Qual é<br/>a<br/>Música?
</p>
<a href="#"
class="botao"
(click)="novoJogo()">Play
</a>
</div>
COMPONENT ...relevant...:
play(): void {
let player = document.getElementById("player");
player.play();
}
}
CAN'T ACCESS JS METHODS
Typecast element to HTMLAudioElement
function play(): void {
let player = <HTMLAudioElement>document.getElementById("player");
player.play();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With