2023-11-10 23:51:50 -05:00
|
|
|
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-10 23:51:50 -05:00
|
|
|
import { Box, Icon, ProgressBar } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
|
2023-11-13 16:19:09 -05:00
|
|
|
import { SpeakerIcon } from '../misc/audio-icons.js';
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-21 01:29:46 -05:00
|
|
|
const AUDIO_MAX = 1.5;
|
|
|
|
|
2023-11-10 23:51:50 -05:00
|
|
|
|
|
|
|
export default () => Box({
|
|
|
|
className: 'osd',
|
|
|
|
children: [
|
|
|
|
Icon({
|
|
|
|
hpack: 'start',
|
2023-11-13 16:19:09 -05:00
|
|
|
binds: [['icon', SpeakerIcon, 'value']],
|
|
|
|
}),
|
|
|
|
|
|
|
|
ProgressBar({
|
|
|
|
vpack: 'center',
|
2023-11-21 01:29:46 -05:00
|
|
|
|
|
|
|
connections: [[Audio, (self) => {
|
|
|
|
if (!Audio.speaker) {
|
2023-11-10 23:51:50 -05:00
|
|
|
return;
|
2023-11-21 01:29:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
self.value = Audio.speaker ?
|
|
|
|
Audio.speaker.volume / AUDIO_MAX :
|
|
|
|
0;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
2023-11-13 16:19:09 -05:00
|
|
|
self.sensitive = !Audio.speaker?.stream.isMuted;
|
2023-11-10 23:51:50 -05:00
|
|
|
|
|
|
|
const stack = self.get_parent().get_parent();
|
2023-11-21 01:29:46 -05:00
|
|
|
|
2023-11-10 23:51:50 -05:00
|
|
|
stack.shown = 'audio';
|
|
|
|
stack.resetTimer();
|
|
|
|
}, 'speaker-changed']],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|