I am working on a project and came across a little issue: So, i have a video tag:
<video muted autoPlay loop src={video}>
and i just want a single custom button/control to unmute and mute the video. Am i right when i think of something using reactHooks and something like onClick={(handleChange => ??, or something like this:
<button onClick={() => toggle(!mute)}>
{mute ? 'Mute' : 'Unmute'}
</button>
but i do not really know how to setup the mute function in order to control the video tag.
Can someone help me out?
I managed to solve it, this is how:
const [muted, setMuted] = useState(true);
const handleToggleMute = () => setMuted(current => !current);
<button onClick={handleToggleMute} className="control">Unmute</button>