【问题标题】:Is there any way to prefetch or cache audio in React Native?有没有办法在 React Native 中预取或缓存音频?
【发布时间】:2019-06-03 00:45:24
【问题描述】:

是否有任何方法可以在 React Native 中预取音频,或者是否有任何库允许我这样做?

【问题讨论】:

    标签: android react-native caching audio


    【解决方案1】:

    由于缺乏信息,我相信您在问是否可以使用 react native 下载音频? 你可以使用类似https://www.npmjs.com/package/rn-fetch-blob 这将允许您将流保存到手机存储中,为您提供手机上文件的路径,然后您可以将其保存以供以后重复使用。

    他们文档中的一个例子。

    RNFetchBlob.config({
    // add this option that makes response data to be stored as a file,
    // this is much more performant.
    fileCache : true,
    })
    .fetch('GET', 'http://www.example.com/file/example.zip', {
      //some headers ..
    })
    .then((res) => {
      // the temp file path
      console.log('The file saved to ', res.path())
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-12
      • 1970-01-01
      • 1970-01-01
      • 2016-10-30
      相关资源
      最近更新 更多