Files
cnix/home/core/gui/ags/utils/audio.js
2024-07-15 14:39:56 +02:00

31 lines
710 B
JavaScript

import { Audio, Icons } from "../imports.js";
export const audioIcon = () => {
if (Audio.speaker?.stream.isMuted) return Icons.volume.muted;
const vol = Audio.speaker?.volume * 100;
const icon = [
[101, "overamplified"],
[67, "high"],
[34, "medium"],
[1, "low"],
[0, "muted"],
].find(([threshold]) => threshold <= vol)[1];
return Icons.volume[icon];
};
export const micIcon = () => {
if (Audio.microphone?.stream.isMuted) return Icons.microphone.muted;
const vol = Audio.microphone?.volume * 100;
const icon = [
[67, "high"],
[34, "medium"],
[1, "low"],
[0, "muted"],
].find(([threshold]) => threshold <= vol)[1];
return Icons.microphone[icon];
};