music controls: allow many players (#243)

This commit is contained in:
end-4
2024-02-07 23:29:45 +07:00
parent 94c58d883e
commit 30a40a9e21
@@ -351,28 +351,16 @@ export default () => Revealer({
revealChild: false,
child: Box({
setup: (self) => self.hook(Mpris, box => {
let foundPlayer = false;
box.children.forEach(child => {
child.destroy();
child = null;
});
Mpris.players.forEach((player, i) => {
if (isRealPlayer(player)) {
foundPlayer = true;
box.children.forEach(child => {
child.destroy();
child = null;
});
const newInstance = MusicControlsWidget(player);
box.children = [newInstance];
box.add(newInstance);
}
});
if (!foundPlayer) {
const children = box.get_children();
for (let i = 0; i < children.length; i++) {
const child = children[i];
child.destroy();
child = null;
}
return;
}
}, 'notify::players'),
}),
setup: (self) => self.hook(showMusicControls, (revealer) => {