react-native - 'uri.match' 未定义试图将音频文件插入视频源

标签 react-native expo react-native-video

这是我关于这个 <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/

相关文章:

javascript - React-Native 方法不会覆盖或实现父类(super class)型的方法

node.js - npm 错误! cb() 从未调用过

ios - 如何修复 'Video play but don' t have sound on iOS with expo'

javascript - react-native-video:无法读取 null 的属性 'Constants'

android - 我们可以使用 React Native 在 Android 系统中运行简单的 shell 脚本吗?

android - 如何在 React Native 中使用 "Spinner"模式 "DatePickerAndroid"而没有任何对话框/模式/弹出窗口?

node.js - Node 服务器卡在加载依赖图上

android - error "Process ' command './node_modules/expokit/detach-scripts/run-exp.sh' ' finished with non-zero exit value 1"whie getting android apk file

react-native - 在外部网络上托管 Expo 应用程序?