import { Sound } from 'react-native-sound'
import React, { Component } from 'react'
import { Button } from 'react-native'
//import Audio from 'react-native-audio'
class About extends Component {
playTrack = () => {
const track = new Sound('geetha_govindham_song.mp3','', null, (e) => {
if (e) {
console.log('error loading track:', e)
} else {
//track.play()
}
})
track.play()
}
render() {
console.log("CCCCC", JSON.stringify(Sound));
return <Button title="play me" onPress={this.playTrack} />
}
}
export default About
After executing this we got the error like undefined is not a constructor.
在这里,我使用了react-native-sound模块来播放mp3歌曲。但是,我收到了类似图片中所示的错误。请给我任何解决问题的建议。
答案 0 :(得分:0)
您可以尝试使用require吗?
const Sound = require('react-native-sound');
答案 1 :(得分:0)
您应该执行默认导入:
import Sound from ‘react-native-sound’
您可以在项目的自述文件中找到示例:https://github.com/zmxv/react-native-sound/blob/master/README.md