зеркало из https://github.com/nextcloud/spreed.git
Play waiting sound when you are alone in a call
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
09341afb03
Коммит
32d3cde52b
Двоичный файл не отображается.
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -24,14 +24,30 @@ export const Sounds = {
|
|||
isInCall: false,
|
||||
lastPlayedJoin: 0,
|
||||
lastPlayedLeave: 0,
|
||||
backgroundAudio: null,
|
||||
backgroundInterval: null,
|
||||
|
||||
_playFile(soundFile) {
|
||||
_playSounceOnce(soundFile) {
|
||||
const file = generateFilePath('spreed', 'img', soundFile)
|
||||
const audio = new Audio(file)
|
||||
audio.play()
|
||||
},
|
||||
|
||||
playJoin(force) {
|
||||
async playWaiting() {
|
||||
if (!this.backgroundAudio) {
|
||||
console.debug('Loading waiting sound')
|
||||
const file = generateFilePath('spreed', 'img', 'LibremPhoneCall.ogg')
|
||||
this.backgroundAudio = new Audio(file)
|
||||
}
|
||||
|
||||
this.backgroundInterval = setInterval(() => {
|
||||
console.debug('Playing waiting sound')
|
||||
this.backgroundAudio.play()
|
||||
}, 7000)
|
||||
},
|
||||
|
||||
async playJoin(force, playWaitingSound) {
|
||||
clearInterval(this.backgroundInterval)
|
||||
if (force) {
|
||||
this.isInCall = true
|
||||
} else if (!this.isInCall) {
|
||||
|
@ -55,10 +71,16 @@ export const Sounds = {
|
|||
this.lastPlayedJoin = currentTime
|
||||
console.debug('Playing join sound')
|
||||
}
|
||||
this._playFile('LibremEmailNotification.ogg')
|
||||
|
||||
this._playSounceOnce('LibremEmailNotification.ogg')
|
||||
|
||||
if (playWaitingSound) {
|
||||
this.playWaiting()
|
||||
}
|
||||
},
|
||||
|
||||
playLeave(force) {
|
||||
async playLeave(force, playWaitingSound) {
|
||||
clearInterval(this.backgroundInterval)
|
||||
if (!this.isInCall) {
|
||||
return
|
||||
}
|
||||
|
@ -78,6 +100,11 @@ export const Sounds = {
|
|||
console.debug('Playing leave sound')
|
||||
}
|
||||
this.lastPlayedLeave = currentTime
|
||||
this._playFile('LibremTextMessage.ogg')
|
||||
|
||||
this._playSounceOnce('LibremTextMessage.ogg')
|
||||
|
||||
if (playWaitingSound) {
|
||||
this.playWaiting()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ function usersChanged(signaling, newUsers, disconnectedSessionIds) {
|
|||
const sessionId = user.sessionId || user.sessionid
|
||||
if (!sessionId || sessionId === currentSessionId || previousUsersInRoom.indexOf(sessionId) !== -1) {
|
||||
if (sessionId === currentSessionId && previousUsersInRoom.indexOf(sessionId) !== -1) {
|
||||
Sounds.playJoin(true)
|
||||
Sounds.playJoin(true, newUsers.length === 1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -352,15 +352,15 @@ function usersChanged(signaling, newUsers, disconnectedSessionIds) {
|
|||
playLeaveSound = true
|
||||
})
|
||||
|
||||
previousUsersInRoom = arrayDiff(previousUsersInRoom, disconnectedSessionIds)
|
||||
|
||||
if (selfInCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED) {
|
||||
if (playJoinSound) {
|
||||
Sounds.playJoin()
|
||||
} else if (playLeaveSound) {
|
||||
Sounds.playLeave()
|
||||
Sounds.playLeave(false, previousUsersInRoom.length === 0)
|
||||
}
|
||||
}
|
||||
|
||||
previousUsersInRoom = arrayDiff(previousUsersInRoom, disconnectedSessionIds)
|
||||
}
|
||||
|
||||
function usersInCallChanged(signaling, users) {
|
||||
|
@ -393,7 +393,7 @@ function usersInCallChanged(signaling, users) {
|
|||
|
||||
if (previousSelfInCall === PARTICIPANT.CALL_FLAG.DISCONNECTED
|
||||
&& selfInCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED) {
|
||||
Sounds.playJoin(true)
|
||||
Sounds.playJoin(true, Object.keys(userMapping).length === 0)
|
||||
} else if (previousSelfInCall !== PARTICIPANT.CALL_FLAG.DISCONNECTED
|
||||
&& selfInCall === PARTICIPANT.CALL_FLAG.DISCONNECTED) {
|
||||
Sounds.playLeave(true)
|
||||
|
|
Загрузка…
Ссылка в новой задаче