Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} = settings
firebase.initializeApp({
apiKey: FIREBASE_API_KEY,
authDomain: FIREBASE_AUTH_DOMAIN,
databaseURL: FIREBASE_DATABASE_URL,
projectId: FIREBASE_PROJECT_ID,
storageBucket: FIREBASE_STORAGE_BUCKET,
messagingSenderId: FIREBASE_MESSAGING_SENDER_ID,
})
const { startLoadingProcess, navigation } = this.props
startLoadingProcess(navigation)
Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
playsInSilentModeIOS: true,
shouldDuckAndroid: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
playThroughEarpieceAndroid: false,
staysActiveInBackground: false,
})
.then((response) => {
// console.log('Audio Mode Setup')
})
.catch((error) => console.log(error))
}
//If playing - stop
if (soundObject) {
soundObject
.stopAsync()
.then(() => {
return soundObject.unloadAsync()
})
.then(() => {})
.catch((error) => console.log(error))
}
//If id id different than last id play new
if (playingRecording !== _id) {
Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
playsInSilentModeIOS: true,
shouldDuckAndroid: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
playThroughEarpieceAndroid: false,
staysActiveInBackground: false,
})
.then(() => {
const newSoundObject = new Audio.Sound()
newSoundObject
.loadAsync({ uri: audio })
.then((response) => {
newSoundObject.setOnPlaybackStatusUpdate((statusData) => {
const { didJustFinish } = statusData
if (didJustFinish) {
this.setState({ playingRecording: '', soundObject: undefined })
}
.catch((error) => {
console.log(error)
Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
playsInSilentModeIOS: true,
shouldDuckAndroid: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
playThroughEarpieceAndroid: false,
staysActiveInBackground: false,
})
})
}
valueName: 'staysActiveInBackground',
disabled: !this.state.modeToSet.playsInSilentModeIOS,
value: !this.state.modeToSet.playsInSilentModeIOS ? false : undefined,
})}
{this._renderModeSelector({
title: 'Mix with others',
value: Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS,
})}
{this._renderModeSelector({
title: 'Do not mix',
value: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
})}
{this._renderModeSelector({
disabled: this.state.modeToSet.playsInSilentModeIOS === false,
title: 'Duck others',
value: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
})}
<button disabled="{this._modesEqual(this.state.modeToSet," style="{{" title="Apply changes">
);
}
}</button>
handleStartAudioRecording = () => {
Audio.setAudioModeAsync({
allowsRecordingIOS: true,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS,
playsInSilentModeIOS: true,
shouldDuckAndroid: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
playThroughEarpieceAndroid: false,
staysActiveInBackground: false,
})
.then((response) => {
return Permissions.askAsync(Permissions.AUDIO_RECORDING)
})
.then((response) => {
const { status, expires, permissions } = response
if (status === 'granted') {
const newRecording = new Audio.Recording()
newRecording
.prepareToRecordAsync(Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY)
.then((response) => {
value={audioMode.staysActiveInBackground}
disabled={!isAudioEnabled || !audioMode.playsInSilentModeIOS}
onValueChange={value => {
const newAudioMode = { ...audioMode, staysActiveInBackground: value };
setAudioMode(newAudioMode);
}}
/>
) : null}
{
const newAudioMode = { ...audioMode, interruptionModeIOS: value };
setAudioMode(newAudioMode);
}}
/>
);
}