Following is my code, the audio only plays when the disconnected are disconnected. How do I adjust to playing even the headphones are not disconnected?
import React from 'react';
import {StyleSheet, Text, View, Button} from 'react-native';
import Audio from 'expo';
export default class App extends React.Component {
componentDidMount = async () => {
onPlaybackStatusUpdate = null
initialStatus = {}
downloadFirst = true
source = {uri: 'https://www.word.today/uploads/word/pronunciation_audio/727/consistent.mp3'}
const soundObject = new Expo.Audio.Sound();
soundObject.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
await soundObject.loadAsync(source, initialStatus, downloadFirst);
soundObject.playAsync();
console.log("page loaded");
}
onPressLearnMore = async () => {
onPlaybackStatusUpdate = null
initialStatus = {}
downloadFirst = true
source = {uri: 'https://www.word.today/uploads/word/pronunciation_audio/727/consistent.mp3'}
const soundObject = new Expo.Audio.Sound();
soundObject.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
await soundObject.loadAsync(source, initialStatus, downloadFirst);
soundObject.playAsync();
console.log("this is a test");
}
render() {
return (
<View style={styles.container}>
<Button title="play audio" color="blue" onPress={this.onPressLearnMore}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});