小编Vic*_*teh的帖子

使用 React Native 在手机上搜索音频文件

我正在使用 react native 开发音乐应用程序,但我一直在努力找出搜索和播放已保存在客户端手机上的音频文件的最佳方式。我只是不确定解决这个问题的最佳模块/库是什么,或者 iOS/Android 操作系统是否完全允许这种类型的用户文件访问。

我正在使用react-native-sound播放音频文件,我找到了react-native-fs模块,这看起来很接近我觉得我需要搜索音频文件的内容。有一个 readDir 函数,但你向它传递目录路径常量,如 MainBundlePath、CachesDirectoryPath、DocumentDirectoryPath 等:

// require the module
var RNFS = require('react-native-fs');

// get a list of files and directories in the main bundle
RNFS.readDir(RNFS.MainBundlePath)
Run Code Online (Sandbox Code Playgroud)

包括: 1. MainBundlePath - 主包目录的绝对路径 2. CachesDirectoryPath - 缓存目录的绝对路径 3. DocumentDirectoryPath - 文档目录的绝对路径

这些目录中的任何一个是我寻找已存储在客户端手机上的音频文件的地方吗?

react-native

5
推荐指数
2
解决办法
5619
查看次数

标签 统计

react-native ×1