Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native ';uri.match';试图将音频文件插入视频源时未定义_React Native_Expo_React Native Video - Fatal编程技术网

React native ';uri.match';试图将音频文件插入视频源时未定义

React native ';uri.match';试图将音频文件插入视频源时未定义,react-native,expo,react-native-video,React Native,Expo,React Native 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.

这是我关于
元素的代码

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"}  
/>
以下是版本

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本地视频:3.2.1

我正在尝试从本地软件包加载音频资源,但我似乎无法使其正常工作,如果我从该文件夹中删除音频文件,它会抛出一个错误,无法找到它,因此它肯定找到了该文件


我想得到一些帮助,我找到了解决办法。变量
audioFile
本身包含
uri

所以不是


试试这个:


请注意,我已直接将
this.audioFile
传递给源代码


更重要的是,要显示视频,必须通过高度和宽度。

这就是在我的用例中工作的原因


你找到解决办法了吗?@KishanBharda是的,请看我的答案OK。这个不错。你能告诉我当我有像
photos://23E23...
?如果照片在您的设备上,我相信您只需使用URI位即可。我以前从未尝试过以这种方式显示照片。我知道您可以使用
{uri:“…”}
显示base64图像,因此如果您可以从本地照片查找中获取base64图像数据,您可以这样显示它。
TypeError: uri.match is not a function. (In 'uri.match(/^\//)', 'uri.match' is undefined)