这是我的代码。我试图通过单击按钮来播放 mp3,但我遇到了这个我不理解的构造函数错误(我对 react-native 编码很陌生)。
import React, { Component } from 'react';
import { Text, View, TouchableOpacity } from 'react-native';
import Sound from 'react-native-sound';
export default class SoundPlayer extends Component {
sound = new Sound(
'/Users/viswajithkumar/DharmaWorldwide/Screens/assets/Audio/FrenchTouch.mp3'
);
playSound = () => {
this.sound.play();
};
render() {
return (
<View>
<TouchableOpacity onPress={this.playSound}>
<View>
<Text>Start</Text>
</View>
</TouchableOpacity>
</View>
);
}
}