这是我关于这个 <Video />
的代码元素
class Menu extends Component {
...
audioFile = null
componentWillMount(){
this.audioFile = require('../../assets/audio/subtle.mp3');
}
}
<Video source={{uri: this.audioFile}} // Can be a URL or a local file.
ref={(ref) => {
this.player = ref
}}
onError={this.audioError}
audioOnly
style={styles.backgroundVideo}
playInBackground
playWhenInactive
ignoreSilentSwitch={"ignore"}
/>
我得到的具体错误是...
TypeError: uri.match is not a function. (In 'uri.match(/^\//)', 'uri.match' is undefined)
这是版本
expo: 30.0.0
expokit: 1.7.1
react: 16.3.1
react-native: https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz
react-native-video: 3.2.1
我正在尝试从此处的本地包加载音频 Assets ,但我似乎无法让它工作,如果我从该文件夹中删除音频文件,它会抛出找不到它的错误所以它肯定能找到文件。
希望得到一些帮助
最佳答案
这就是它在我的用例中起作用的原因
<Video source={require('../../assets/audio/file.mp3')} ... />
关于react-native - 'uri.match' 未定义试图将音频文件插入视频源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52616346/