mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-06 13:18:27 +02:00
Rewrite volume control feature
This commit is contained in:
@@ -91,5 +91,26 @@ export const BxExposed = {
|
||||
BxEvent.dispatch(window, BxEvent.TITLE_INFO_READY);
|
||||
|
||||
return titleInfo;
|
||||
},
|
||||
|
||||
setupGainNode: ($media: HTMLMediaElement, audioStream: MediaStream) => {
|
||||
if ($media instanceof HTMLAudioElement) {
|
||||
$media.muted = true;
|
||||
$media.addEventListener('playing', e => {
|
||||
$media.muted = true;
|
||||
$media.pause();
|
||||
});
|
||||
} else {
|
||||
$media.muted = true;
|
||||
$media.addEventListener('playing', e => {
|
||||
$media.muted = true;
|
||||
});
|
||||
}
|
||||
|
||||
const audioCtx = STATES.currentStream.audioContext!;
|
||||
const source = audioCtx.createMediaStreamSource(audioStream);
|
||||
|
||||
const gainNode = audioCtx.createGain(); // call monkey-patched createGain() in BxAudioContext
|
||||
source.connect(gainNode).connect(audioCtx.destination);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user