How to use the expo-av.Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS function in expo-av

To help you get started, we’ve selected a few expo-av examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SCasarotto / casarotto-chat / src / pages / Loading / Loading.js View on Github external
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))
	}
github EvanBacon / Instagram / App.js View on Github external
_applyMode = async () => {
    try {
      await Audio.setAudioModeAsync({
        // ...this.state.modeToSet,
        playThroughEarpieceAndroid: true,
        interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
        shouldDuckAndroid: true,
        // iOS values don't matter, this is Android-only selector
        allowsRecordingIOS: false,
        playsInSilentModeIOS: false,
        interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
      });
      // this.setState({ setMode: this.state.modeToSet });
    } catch (error) {
      alert(error.message);
    }
  };
  render() {
github expo / expo / apps / native-component-list / src / screens / AV / AudioModeSelector.android.tsx View on Github external
interface State {
  modeToSet: Mode;
  setMode: Mode;
}

export default class AudioModeSelector extends React.Component<{}, State> {
  readonly state: State = {
    modeToSet: {
      interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
      shouldDuckAndroid: true,
      playThroughEarpieceAndroid: false,
      staysActiveInBackground: false,
    },
    setMode: {
      interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
      shouldDuckAndroid: true,
      playThroughEarpieceAndroid: false,
      staysActiveInBackground: false,
    },
  };

  _applyMode = async () => {
    try {
      await Audio.setAudioModeAsync({
        ...this.state.modeToSet,
        // iOS values don't matter, this is Android-only selector
        allowsRecordingIOS: false,
        playsInSilentModeIOS: false,
        interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
      });
      this.setState({ setMode: this.state.modeToSet });
github SCasarotto / casarotto-chat / src / pages / Main / AudioCustom.js View on Github external
.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 })
								}
							})
							return newSoundObject.playAsync()
						})
github SCasarotto / casarotto-chat / src / pages / Main / Main.js View on Github external
.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,
				})
			})
	}
github SCasarotto / casarotto-chat / src / pages / Main / Main.js View on Github external
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) => {
							return newRecording.startAsync()
						})
						.then((response) => {
github expo / expo / apps / native-component-list / src / screens / AV / AudioModeSelector.android.tsx View on Github external
interface Mode {
  interruptionModeAndroid: number;
  shouldDuckAndroid: boolean;
  playThroughEarpieceAndroid: boolean;
  staysActiveInBackground: boolean;
}

interface State {
  modeToSet: Mode;
  setMode: Mode;
}

export default class AudioModeSelector extends React.Component<{}, State> {
  readonly state: State = {
    modeToSet: {
      interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
      shouldDuckAndroid: true,
      playThroughEarpieceAndroid: false,
      staysActiveInBackground: false,
    },
    setMode: {
      interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
      shouldDuckAndroid: true,
      playThroughEarpieceAndroid: false,
      staysActiveInBackground: false,
    },
  };

  _applyMode = async () => {
    try {
      await Audio.setAudioModeAsync({
        ...this.state.modeToSet,
github expo / expo / apps / native-component-list / src / screens / AV / AudioModeSelector.android.tsx View on Github external
})}
        {this._renderToggle({
          title: 'Play through earpiece',
          valueName: 'playThroughEarpieceAndroid',
        })}
        {this._renderToggle({
          title: 'Stay active in background',
          valueName: 'staysActiveInBackground',
        })}
        {this._renderModeSelector({
          title: 'Do not mix',
          value: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
        })}
        {this._renderModeSelector({
          title: 'Duck others',
          value: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
        })}
        <button disabled="{this._modesEqual(this.state.modeToSet," style="{{" title="Apply changes">
      
    );
  }
}</button>