-1
I can’t handle very well with The Expo-av (I don’t think anyone knows why I can’t find tutorials), but what I’m doing wrong?
import React,{ Component } from 'react';
import { View, TouchableOpacity } from 'react-native';
import { Audio } from 'expo-av'
import Icon from 'react-native-vector-icons/Ionicons';
import styles from './styles';
export default class ButtonsManager extends Component {
async componentDidAmount() {
Audio.setAudioModeAsync({
allowsRecordingIOS: false,
interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
playsInSilentModeIOS: true,
interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS,
shouldDuckAndroid: true,
staysActiveInBackground: true,
playThroughEarpieceAndroid: true
});
this.sound = new Audio.Sound();
const status = {
shouldPlay: false
};
this.sound.loadAsync(require('../../../../musics/luxuria.mp3'), status, false);
}
playSound() {
this.sound.playAsync();
}
render() {
return(
<View style={styles.container}>
<TouchableOpacity style={styles.buttonContainer} onPress={this.playSound.bind(this)}>
<Icon style={styles.icon} size={50} name='ios-pause' />
</TouchableOpacity>
</View>
);
}
}
Understood, corrected the error, but now returns this:
TypeError: null is not object (evaluating 'this.state.sound.playAsync')
– Nycollas
Could you give me another hand? I really don’t know how to proceed...
– Nycollas