Typescript function to mute HTML audio

Viewed 1116

I have audio that auto-plays on screen load. I am trying to include a button that will mute the audio using Typescript. The app is built in Angular4. I have tried using

document.getElementById('mute').addEventListener('click', function (e)
{
e = e || window.event;
audio.muted = !audio.muted;
e.preventDefault();
}, false);

but am getting Event is not assigned to MouseEvent, it also says muted does not exist on type HTMLElement.

Is there a way to do this in the main.ts file?

1 Answers
Related