how to make onclick
the sound start only on a side of the earphones
like for example right or left.
something like this: https://www.onlinemictest.com/sound-test/
so if it plays the sound on the left it, the right earphone doesn't need to make any sound.
I think it can be done by using volumes or something like that. how to do that?
(I can't edit the sound in a video editor, I want it will automatically done by javascript)
function playSound(options) {
const choosedDirection = () => {
return Object.keys(options)
.reverse()
.find(
(direction) => direction === "left" || direction === "right",
);
};
const audio = new Audio("audio.mp3");
switch (choosedDirection()) {
case "left":
audio.play();
// how to make here play only on the left side
// by making the volume high on the left and 0 on the right
break;
case "right":
audio.play();
// how to make here play only on the right side
// by making the volume high on the right and 0 on the left
break;
}
}
<head>
<script src="https://cdn.tailwindcss.com/"></script>
</head>
<body >
<div >
<div >
<!-- left -->
<button title="