Audioplayers package in Flutter to play 20 songs simultaneously

27 Views Asked by At

// I am using the audioplayers package in Flutter to play 20 songs simultaneously but there is a little delay when I play them. Is there any way to resolve this?

List<File> files = [];
  
Future<void> playMusicWithSaxophones(int currentIndex) async {
    files.clear();
    for (int i = 0; i < songController.allSongs[currentIndex].mixerList.length; i++) {
        var file = await DefaultCacheManager().getSingleFile(songController.allSongs[currentIndex].mixerList[i].path!);
        files.add(file);
        await songController.allSongs[currentIndex].mixerList[i].audioPlayer?.setSourceDeviceFile(file.path);
    }

    for (int i = 0; i < songController.allSongs[currentIndex].mixerList.length; i++) {
        if(files[i].path.isNotEmpty){
            songController.allSongs[currentIndex].mixerList[i].audioPlayer?.seek(position);
            songController.allSongs[currentIndex].mixerList[i].audioPlayer?.resume();
        }
    }
}
0

There are 0 best solutions below