Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-03-27 11:13:37 +0300
committerJoas Schilling <coding@schilljs.com>2021-03-26 11:25:33 +0300
commit32d3cde52b48803408412cf679ecab9de4e2fbe7 (patch)
tree811e530b792c9b01e7ee8f551d116d3c267c3179
parent09341afb037a24ae34b3c667df1395aff0eb690e (diff)
Play waiting sound when you are alone in a call
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--img/LibremPhoneCall.oggbin0 -> 192522 bytes
-rw-r--r--img/LibremPowerOn.oggbin0 -> 102351 bytes
-rw-r--r--img/LibremVideoCall.oggbin0 -> 213861 bytes
-rw-r--r--src/utils/sounds.js37
-rw-r--r--src/utils/webrtc/webrtc.js10
5 files changed, 37 insertions, 10 deletions
diff --git a/img/LibremPhoneCall.ogg b/img/LibremPhoneCall.ogg
new file mode 100644
index 000000000..51d1bc0ac
--- /dev/null
+++ b/img/LibremPhoneCall.ogg
Binary files differ
diff --git a/img/LibremPowerOn.ogg b/img/LibremPowerOn.ogg
new file mode 100644
index 000000000..f290a622d
--- /dev/null
+++ b/img/LibremPowerOn.ogg
Binary files differ
diff --git a/img/LibremVideoCall.ogg b/img/LibremVideoCall.ogg
new file mode 100644
index 000000000..9297f1dca
--- /dev/null
+++ b/img/LibremVideoCall.ogg
Binary files differ
diff --git a/src/utils/sounds.js b/src/utils/sounds.js
index d7249e46d..96582df74 100644
--- a/src/utils/sounds.js
+++ b/src/utils/sounds.js
@@ -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()
+ }
},
}
diff --git a/src/utils/webrtc/webrtc.js b/src/utils/webrtc/webrtc.js
index 0232c636f..eaceef1c2 100644
--- a/src/utils/webrtc/webrtc.js
+++ b/src/utils/webrtc/webrtc.js
@@ -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)