EXPO:将文件系统导出到文件,进入android文件夹

时间:2019-09-09 13:13:11

标签: react-native expo

早上好, 实际上,我正在使用这台录音机。

https://snack.expo.io/@riwu/audio-recorder

如何像下载一样将文件保存到设备的文件夹中?

谢谢

async _stopRecordingAndEnablePlayback() {
        this.setState({
            isLoading: true,
        });
        try {
            await this.recording.stopAndUnloadAsync();
        } catch (error) {
            // Do nothing -- we are already unloaded.
        }
        const info = await FileSystem.getInfoAsync(this.recording.getURI());

        console.log(`FILE INFO: ${JSON.stringify(info)}`);

        await Audio.setAudioModeAsync({
            allowsRecordingIOS: false,
            interruptionModeIOS: Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX,
            playsInSilentModeIOS: true,
            playsInSilentLockedModeIOS: true,
            shouldDuckAndroid: true,
            interruptionModeAndroid: Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX,
            playThroughEarpieceAndroid: false,
            staysActiveInBackground: true,
        });


1 个答案:

答案 0 :(得分:0)

添加了它。而且有效!!!!

    takePictureAndCreateAlbum = async () => {

        const asset = await MediaLibrary.createAssetAsync(this.recording.getURI());
        MediaLibrary.createAlbumAsync('Expo', asset)
          .then(() => {
            console.log('Album created!');
          })
          .catch(error => {
            console.log('err', error);
          });
      }

非常感谢您!