Add ability to set stream audio playing in background

This commit is contained in:
Max Goodhart
2020-08-26 23:28:04 -07:00
parent 93a29ecfac
commit d8e51776e9
6 changed files with 59 additions and 9 deletions

View File

@@ -257,6 +257,10 @@ export default class StreamWindow extends EventEmitter {
}
}
setViewBackgroundListening(viewIdx, listening) {
this.sendViewEvent(viewIdx, listening ? 'BACKGROUND' : 'UNBACKGROUND')
}
setViewBlurred(viewIdx, blurred) {
this.sendViewEvent(viewIdx, blurred ? 'BLUR' : 'UNBLUR')
}

View File

@@ -270,6 +270,8 @@ async function main() {
const onMessage = async (msg, respond) => {
if (msg.type === 'set-listening-view') {
streamWindow.setListeningView(msg.viewIdx)
} else if (msg.type === 'set-view-background-listening') {
streamWindow.setViewBackgroundListening(msg.viewIdx, msg.listening)
} else if (msg.type === 'set-view-blurred') {
streamWindow.setViewBlurred(msg.viewIdx, msg.blurred)
} else if (msg.type === 'set-custom-streams') {

View File

@@ -141,6 +141,8 @@ const viewStateMachine = Machine(
on: {
MUTE: '.muted',
UNMUTE: '.listening',
BACKGROUND: '.background',
UNBACKGROUND: '.muted',
},
states: {
muted: {
@@ -149,6 +151,13 @@ const viewStateMachine = Machine(
listening: {
entry: 'unmuteAudio',
},
background: {
on: {
// Ignore normal audio swapping.
MUTE: {},
},
entry: 'unmuteAudio',
},
},
},
video: {