<legend id='SfhiG'><style id='SfhiG'><dir id='SfhiG'><q id='SfhiG'></q></dir></style></legend>

  • <tfoot id='SfhiG'></tfoot>

        • <bdo id='SfhiG'></bdo><ul id='SfhiG'></ul>
      1. <small id='SfhiG'></small><noframes id='SfhiG'>

      2. <i id='SfhiG'><tr id='SfhiG'><dt id='SfhiG'><q id='SfhiG'><span id='SfhiG'><b id='SfhiG'><form id='SfhiG'><ins id='SfhiG'></ins><ul id='SfhiG'></ul><sub id='SfhiG'></sub></form><legend id='SfhiG'></legend><bdo id='SfhiG'><pre id='SfhiG'><center id='SfhiG'></center></pre></bdo></b><th id='SfhiG'></th></span></q></dt></tr></i><div id='SfhiG'><tfoot id='SfhiG'></tfoot><dl id='SfhiG'><fieldset id='SfhiG'></fieldset></dl></div>

        要求在 React Native 中选择音频文件?

        Ask to choose Audio file in React Native?(要求在 React Native 中选择音频文件?)
      3. <legend id='HQJwc'><style id='HQJwc'><dir id='HQJwc'><q id='HQJwc'></q></dir></style></legend>

        <small id='HQJwc'></small><noframes id='HQJwc'>

            • <i id='HQJwc'><tr id='HQJwc'><dt id='HQJwc'><q id='HQJwc'><span id='HQJwc'><b id='HQJwc'><form id='HQJwc'><ins id='HQJwc'></ins><ul id='HQJwc'></ul><sub id='HQJwc'></sub></form><legend id='HQJwc'></legend><bdo id='HQJwc'><pre id='HQJwc'><center id='HQJwc'></center></pre></bdo></b><th id='HQJwc'></th></span></q></dt></tr></i><div id='HQJwc'><tfoot id='HQJwc'></tfoot><dl id='HQJwc'><fieldset id='HQJwc'></fieldset></dl></div>
                <tbody id='HQJwc'></tbody>
                <bdo id='HQJwc'></bdo><ul id='HQJwc'></ul>

                  <tfoot id='HQJwc'></tfoot>

                  本文介绍了要求在 React Native 中选择音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有将歌曲上传到我们 API 的应用,

                  I have App for upload Songs to our API,

                  但我找不到一个库,例如 RN-image-picker 询问用户他想选择哪张照片,

                  but I can't find a library for that, Like RN-image-picker that ask the user which photo he wants to choose,

                  除了文件特别是音频"之外,还有什么类似的东西

                  So is there anything like this but for File "especially Audio"

                  我正在尝试 react-native-fs 并使用他在 README 中提供的示例代码片段,但是当我调用它时,我在日志中得到了一个函数

                  I'm trying react-native-fs and use example code snippet he provides in README but when I invoke it I got a function as result in logs

                  chooseFile = () => {
                      RNFS.readDir(RNFS.DocumentDirectoryPath)
                        .then(result => {
                          console.log('GOT RESULT', result); // here i got functions as result
                          // stat the first file
                          return Promise.all([RNFS.stat(result[0].path), result[0].path]);
                        })
                        .then(statResult => {
                          if (statResult[0].isFile()) {
                            // if we have a file, read it
                            return RNFS.readFile(statResult[1], 'utf8');
                          }
                  
                          return 'no file';
                        })
                        .then(contents => {
                          // log the file contents
                          console.log(contents);
                        })
                        .catch(err => {
                          console.log(err.message, err.code);
                        });
                    };
                  

                  编辑

                  在我使用 react-native-document-picker 作为@Tuan Luong 提到并编写一些函数以使用 Axios 将此文件发送到端点之后,我收到了这个错误,

                  EDIT

                  After I use react-native-document-picker as @Tuan Luong mention and write some function to send this file to the endpoint using Axios i got this error,

                   Possible Unhandled Promise Rejection (id: 0):
                  Error: Network Error
                  

                  代码

                  chooseFile = async () => {
                      // Pick a single file
                      try {
                        const res = await DocumentPicker.pick({
                          type: [DocumentPicker.types.audio],
                        });
                        let sound_uri = res.uri;
                        let type = res.type;
                        this.setState({
                          sound_uri,
                          type,
                        });
                      } catch (err) {
                        if (DocumentPicker.isCancel(err)) {
                          // User cancelled the picker, exit any dialogs or menus and move on
                        } else {
                          throw err;
                        }
                      }
                    };
                  
                    sendDatet = async value => {
                      const {type, sound_uri, avatar} = this.state;
                  
                      console.log(avatar, type, sound_uri, value.songName, value.generes_id);
                       // Logs 
                       {/*
                         // avatar => file:///storage/emulated/0/Android/data/com.music/files/Pictures/image7a.jpg
                        // type => audio/mpeg
                        // sound_uri => content://com.android.providers.media.documents/document/audio%3A1530
                       // value.songName => Test song 
                       // value.generes_id => 4
                      *
                                  
                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Gradient Button to background-color blinks on hover(悬停时背景颜色的渐变按钮闪烁)
                  How to make hovering over active button not use hover effect?(如何使悬停在活动按钮上不使用悬停效果?)
                  html javascript show image hover(html javascript 显示图像悬停)
                  How to get css hover values on click?(如何在点击时获得 css 悬停值?)
                  Change background image on link hover(更改链接悬停时的背景图像)
                  Highlight multiple items on hover#39;s condition(突出显示悬停条件下的多个项目)
                    <bdo id='BVJqP'></bdo><ul id='BVJqP'></ul>

                    <small id='BVJqP'></small><noframes id='BVJqP'>

                  • <tfoot id='BVJqP'></tfoot>
                      <i id='BVJqP'><tr id='BVJqP'><dt id='BVJqP'><q id='BVJqP'><span id='BVJqP'><b id='BVJqP'><form id='BVJqP'><ins id='BVJqP'></ins><ul id='BVJqP'></ul><sub id='BVJqP'></sub></form><legend id='BVJqP'></legend><bdo id='BVJqP'><pre id='BVJqP'><center id='BVJqP'></center></pre></bdo></b><th id='BVJqP'></th></span></q></dt></tr></i><div id='BVJqP'><tfoot id='BVJqP'></tfoot><dl id='BVJqP'><fieldset id='BVJqP'></fieldset></dl></div>

                        <tbody id='BVJqP'></tbody>

                          1. <legend id='BVJqP'><style id='BVJqP'><dir id='BVJqP'><q id='BVJqP'></q></dir></style></legend>