Created
September 21, 2020 18:53
-
-
Save soukupl/07934c7f4dcd6b75d737992ea9cdd1ef to your computer and use it in GitHub Desktop.
expo audio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from "react"; | |
import { Audio } from "expo-av"; | |
const audioObject = new Audio.Sound(); | |
const App = () => { | |
useEffect(() => { | |
// init background audio support | |
Audio.setAudioModeAsync({ | |
playsInSilentModeIOS: true, | |
allowsRecordingIOS: false, | |
staysActiveInBackground: true, | |
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS, | |
shouldDuckAndroid: true, | |
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS, | |
playThroughEarpieceAndroid: true, | |
}); | |
audioObject.setOnPlaybackStatusUpdate((status) => { | |
// console.log("OnPlaybackStatusUpdate", { status }); | |
}); | |
}, [audioObject]); | |
return <View /> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"expo": { | |
"ios": { | |
"infoPlist": { | |
"UIBackgroundModes": ["audio"] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment