代码之家  ›  专栏  ›  技术社区  ›  Antoine Auffray

React Native从android res导入音频文件

  •  2
  • Antoine Auffray  · 技术社区  · 6 年前

    我正在制作一个只在Android上显示音频文件的本地应用程序 react-native-sound ,由于它的 Sound.MAIN_BUNDLE

    对于新的共享功能,我需要访问位于 android/app/src/main/res/raw

    我打算用 react-native-share url 通过将其转换为base64来共享它的特性,这意味着我需要能够读取文件内容。

    如何访问这些音频文件?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Martin Zeitler    6 年前

    您可能需要将它们重新定位到web资产中(只能告诉如何使用 Android AssetManager react-native-asset 插件;插件 raw Uri audioRes = Uri.parse("android.resource://com.acme/raw/filename"); (没有后缀)。