mayurpitroda96 / easy_audio_trimmer

This is a Flutter package that allows you to easily trim audio files within your Flutter app.
MIT License
12 stars 31 forks source link

Where its saving?? #19

Open Naguchennai opened 3 months ago

Naguchennai commented 3 months ago

Where its saving?? its not in music folder ... its showing /data/user/0/com.test/app_flutter/Trimmer/1722939802410.mp3 but its not available mp3 list ... how can i move this file to music folder?

zione-kushwaha commented 1 month ago

it's actually saving in the app dirctory ...if you need you to store that in the local music folder then you should copy that stored file from that app directory to desire folder and then delete from app directory eg: Future _saveAudio() async { setState(() { _progressVisibility = true; });

// Request storage permissions
if (await Permission.manageExternalStorage.request().isGranted) {
  String musicDirectoryPath = '/storage/emulated/0/Music';
  Directory musicDirectory = Directory(musicDirectoryPath);

  if (!await musicDirectory.exists()) {
    await musicDirectory.create(recursive: true);
  }

  print('Output directory: $musicDirectoryPath');

  _trimmer.saveTrimmedAudio(
    startValue: _startValue,
    endValue: _endValue,
    audioFolderName: 'Music',
    audioFileName: '${DateTime.now().millisecondsSinceEpoch}.mp3',
    storageDir: StorageDir.externalStorageDirectory,
    onSave: (outputPath) async {
      // Copy the file to the public Music directory
      File savedFile = File(outputPath!);
      String newPath =
          '$musicDirectoryPath/${savedFile.uri.pathSegments.last}';
      await savedFile.copy(newPath);
      await savedFile.delete();

      setState(() {
        _progressVisibility = false;
      });
      debugPrint('OUTPUT PATH: $newPath');
    },
  );
} else {
  setState(() {
    _progressVisibility = false;
  });
  _showSnackBar('Storage permission denied');
}

}