How to call function when audio play button is clicked?

Discussão em 'Angular' iniciado por user3653474, Maio 7, 2025.

  1. user3653474

    user3653474 Guest

    I have this audio player in my component page

    <audio id="player" controls="controls" class="audiocontrol">
    <source src="{{ baseUrl }}storage/{{this.url}}" />
    </audio>


    and in my .ts file i automatically call the play_audio function to play the audio when page loads. This Section is working.

    play_audio()
    {
    try {
    var player = <HTMLAudioElement> document.querySelector('#player');
    player.load();
    var promise = player.play();
    ..
    player.addEventListener("ended", (currentTime)=>{

    });
    }


    but i want to call function of angular when i click on play button manually on audio control.

    Any solution Thanks

    Continue reading...

Compartilhe esta Página