feat(invite-sounds): Add expired and rejected sounds.
This commit is contained in:
parent
2b1c875b91
commit
d89227829f
|
@ -180,6 +180,28 @@ export function getParticipantDisplayName(
|
||||||
: 'Fellow Jitster';
|
: 'Fellow Jitster';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the presence status of a participant associated with the passed id.
|
||||||
|
*
|
||||||
|
* @param {(Function|Object)} stateful - The (whole) redux state, or redux's
|
||||||
|
* {@code getState} function to be used to retrieve the state.
|
||||||
|
* @param {string} id - The id of the participant.
|
||||||
|
* @returns {string} - The presence status.
|
||||||
|
*/
|
||||||
|
export function getParticipantPresenceStatus(
|
||||||
|
stateful: Object | Function, id: string) {
|
||||||
|
if (!id) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const participantById = getParticipantById(stateful, id);
|
||||||
|
|
||||||
|
if (!participantById) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return participantById.presence;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selectors for getting all known participants with fake participants filtered
|
* Selectors for getting all known participants with fake participants filtered
|
||||||
* out.
|
* out.
|
||||||
|
|
|
@ -1,3 +1,21 @@
|
||||||
|
/**
|
||||||
|
* The identifier of the sound to be played when the status of an outgoing call
|
||||||
|
* is expired.
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const OUTGOING_CALL_EXPIRED_SOUND_ID
|
||||||
|
= 'OUTGOING_CALL_EXPIRED_SOUND_ID';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier of the sound to be played when the status of an outgoing call
|
||||||
|
* is rejected.
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export const OUTGOING_CALL_REJECTED_SOUND_ID
|
||||||
|
= 'OUTGOING_CALL_REJECTED_SOUND_ID';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The identifier of the sound to be played when the status of an outgoing call
|
* The identifier of the sound to be played when the status of an outgoing call
|
||||||
* is ringing.
|
* is ringing.
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
|
import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app';
|
||||||
import {
|
import {
|
||||||
getParticipantById,
|
getParticipantPresenceStatus,
|
||||||
PARTICIPANT_UPDATED,
|
PARTICIPANT_JOINED_SOUND_ID,
|
||||||
PARTICIPANT_LEFT
|
PARTICIPANT_LEFT,
|
||||||
|
PARTICIPANT_UPDATED
|
||||||
} from '../base/participants';
|
} from '../base/participants';
|
||||||
import { MiddlewareRegistry } from '../base/redux';
|
import { MiddlewareRegistry } from '../base/redux';
|
||||||
import {
|
import {
|
||||||
|
@ -15,24 +16,39 @@ import {
|
||||||
} from '../base/sounds';
|
} from '../base/sounds';
|
||||||
import {
|
import {
|
||||||
CALLING,
|
CALLING,
|
||||||
|
CONNECTED_USER,
|
||||||
|
EXPIRED,
|
||||||
INVITED,
|
INVITED,
|
||||||
|
REJECTED,
|
||||||
RINGING
|
RINGING
|
||||||
} from '../presence-status';
|
} from '../presence-status';
|
||||||
|
|
||||||
import { UPDATE_DIAL_IN_NUMBERS_FAILED } from './actionTypes';
|
import { UPDATE_DIAL_IN_NUMBERS_FAILED } from './actionTypes';
|
||||||
import {
|
import {
|
||||||
OUTGOING_CALL_START_SOUND_ID,
|
OUTGOING_CALL_EXPIRED_SOUND_ID,
|
||||||
OUTGOING_CALL_RINGING_SOUND_ID
|
OUTGOING_CALL_REJECTED_SOUND_ID,
|
||||||
|
OUTGOING_CALL_RINGING_SOUND_ID,
|
||||||
|
OUTGOING_CALL_START_SOUND_ID
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import {
|
import { sounds } from './sounds';
|
||||||
OUTGOING_CALL_START_FILE,
|
|
||||||
OUTGOING_CALL_RINGING_FILE
|
|
||||||
} from './sounds';
|
|
||||||
|
|
||||||
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||||
|
|
||||||
declare var interfaceConfig: Object;
|
declare var interfaceConfig: Object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps the presence status with the ID of the sound that will be played when
|
||||||
|
* the status is received.
|
||||||
|
*/
|
||||||
|
const statusToRingtone = {
|
||||||
|
[CALLING]: OUTGOING_CALL_START_SOUND_ID,
|
||||||
|
[CONNECTED_USER]: PARTICIPANT_JOINED_SOUND_ID,
|
||||||
|
[EXPIRED]: OUTGOING_CALL_EXPIRED_SOUND_ID,
|
||||||
|
[INVITED]: OUTGOING_CALL_START_SOUND_ID,
|
||||||
|
[REJECTED]: OUTGOING_CALL_REJECTED_SOUND_ID,
|
||||||
|
[RINGING]: OUTGOING_CALL_RINGING_SOUND_ID
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The middleware of the feature invite common to mobile/react-native and
|
* The middleware of the feature invite common to mobile/react-native and
|
||||||
* Web/React.
|
* Web/React.
|
||||||
|
@ -46,56 +62,55 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
if (action.type === PARTICIPANT_UPDATED
|
if (action.type === PARTICIPANT_UPDATED
|
||||||
|| action.type === PARTICIPANT_LEFT) {
|
|| action.type === PARTICIPANT_LEFT) {
|
||||||
oldParticipantPresence
|
oldParticipantPresence
|
||||||
= _getParticipantPresence(store.getState(), action.participant.id);
|
= getParticipantPresenceStatus(
|
||||||
|
store.getState(),
|
||||||
|
action.participant.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case APP_WILL_MOUNT:
|
case APP_WILL_MOUNT:
|
||||||
store.dispatch(
|
for (const [ soundId, sound ] of sounds.entries()) {
|
||||||
registerSound(
|
store.dispatch(registerSound(soundId, sound.file, sound.options));
|
||||||
OUTGOING_CALL_START_SOUND_ID,
|
}
|
||||||
OUTGOING_CALL_START_FILE));
|
|
||||||
|
|
||||||
store.dispatch(
|
|
||||||
registerSound(
|
|
||||||
OUTGOING_CALL_RINGING_SOUND_ID,
|
|
||||||
OUTGOING_CALL_RINGING_FILE,
|
|
||||||
{ loop: true }));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case APP_WILL_UNMOUNT:
|
case APP_WILL_UNMOUNT:
|
||||||
store.dispatch(unregisterSound(OUTGOING_CALL_START_SOUND_ID));
|
for (const soundId of sounds.keys()) {
|
||||||
store.dispatch(unregisterSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
store.dispatch(unregisterSound(soundId));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PARTICIPANT_LEFT:
|
case PARTICIPANT_LEFT:
|
||||||
case PARTICIPANT_UPDATED: {
|
case PARTICIPANT_UPDATED: {
|
||||||
const newParticipantPresence
|
const newParticipantPresence
|
||||||
= _getParticipantPresence(store.getState(), action.participant.id);
|
= getParticipantPresenceStatus(
|
||||||
|
store.getState(),
|
||||||
|
action.participant.id);
|
||||||
|
|
||||||
if (oldParticipantPresence === newParticipantPresence) {
|
if (oldParticipantPresence === newParticipantPresence) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (oldParticipantPresence) {
|
const oldSoundId
|
||||||
case CALLING:
|
= oldParticipantPresence
|
||||||
case INVITED:
|
&& statusToRingtone[oldParticipantPresence];
|
||||||
store.dispatch(stopSound(OUTGOING_CALL_START_SOUND_ID));
|
const newSoundId
|
||||||
break;
|
= newParticipantPresence
|
||||||
case RINGING:
|
&& statusToRingtone[newParticipantPresence];
|
||||||
store.dispatch(stopSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
|
||||||
|
|
||||||
|
if (oldSoundId === newSoundId) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (newParticipantPresence) {
|
if (oldSoundId) {
|
||||||
case CALLING:
|
store.dispatch(stopSound(oldSoundId));
|
||||||
case INVITED:
|
}
|
||||||
store.dispatch(playSound(OUTGOING_CALL_START_SOUND_ID));
|
|
||||||
break;
|
if (newSoundId) {
|
||||||
case RINGING:
|
store.dispatch(playSound(newSoundId));
|
||||||
store.dispatch(playSound(OUTGOING_CALL_RINGING_SOUND_ID));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -109,22 +124,3 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the presence status of a participant associated with the passed id.
|
|
||||||
*
|
|
||||||
* @param {Object} state - The redux state.
|
|
||||||
* @param {string} id - The id of the participant.
|
|
||||||
* @returns {string} - The presence status.
|
|
||||||
*/
|
|
||||||
function _getParticipantPresence(state, id) {
|
|
||||||
if (id) {
|
|
||||||
const participantById = getParticipantById(state, id);
|
|
||||||
|
|
||||||
if (participantById) {
|
|
||||||
return participantById.presence;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +1,44 @@
|
||||||
/**
|
import {
|
||||||
* The name of the sound file which will be played when the status of an
|
OUTGOING_CALL_EXPIRED_SOUND_ID,
|
||||||
* outgoing call is ringing.
|
OUTGOING_CALL_REJECTED_SOUND_ID,
|
||||||
*/
|
OUTGOING_CALL_RINGING_SOUND_ID,
|
||||||
export const OUTGOING_CALL_RINGING_FILE = 'outgoingRinging.wav';
|
OUTGOING_CALL_START_SOUND_ID
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the sound file which will be played when outgoing call is
|
* Maps the sounds IDs with the filenames sounds associated with them.
|
||||||
* started.
|
*
|
||||||
|
* @type {Map<string, string>}
|
||||||
*/
|
*/
|
||||||
export const OUTGOING_CALL_START_FILE = 'outgoingStart.wav';
|
export const sounds = new Map([
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the sound file which will be played when outgoing call is
|
||||||
|
* expired.
|
||||||
|
*/
|
||||||
|
[ OUTGOING_CALL_EXPIRED_SOUND_ID, { file: 'rejected.wav' } ],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the sound file which will be played when outgoing call is
|
||||||
|
* rejected.
|
||||||
|
*/
|
||||||
|
[ OUTGOING_CALL_REJECTED_SOUND_ID, { file: 'rejected.wav' } ],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the sound file which will be played when the status of an
|
||||||
|
* outgoing call is ringing.
|
||||||
|
*/
|
||||||
|
[
|
||||||
|
OUTGOING_CALL_RINGING_SOUND_ID,
|
||||||
|
{
|
||||||
|
file: 'outgoingRinging.wav',
|
||||||
|
options: { loop: true }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the sound file which will be played when outgoing call is
|
||||||
|
* started.
|
||||||
|
*/
|
||||||
|
[ OUTGOING_CALL_START_SOUND_ID, { file: 'outgoingStart.wav' } ]
|
||||||
|
]);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue