英文:
Load large audio files with just_audio
问题
我已经在Flutter中使用just_audio和just_audio_background开发了音乐应用程序。音乐功能和控制正常工作,唯一的问题是当我加载播放列表时,我至少有20首歌曲要加载,它们的持续时间很长。如何减少这个加载时间?
我想改变添加播放列表到播放器的方法。我应该如何实现?
英文:
I have developed music application in Flutter using just_audio and just_audio_background. The music feature and controls are working fine, the only concern is when I am loading the playlist at that time I have at least 20 songs to load and they have a large duration. How can I reduce this loading time duration?
//Generating list
list.add(AudioSource.uri(
Uri.parse(musicDetails!.trackFileUrl!),
tag: MediaItem(
id: currentSongIndex.toString(),
album: musicDetails!.description ?? "",
title: musicDetails!.title ?? "",
artUri: Uri.parse(musicDetails!.coverImage ?? ""),
),
)
);
//Adding entire list to playlist
final playlist = ConcatenatingAudioSource(children: list);
await player.setLoopMode(LoopMode.all);
await player.setAudioSource(playlist,initialIndex: currentSongIndex.value);
I want to change this approach for adding playlist in player. How can I achieve this?
答案1
得分: 1
Android实现支持一个名为useLazyPreparation的选项,默认值为true。该选项在播放时仅在播放器接近项目之前加载每个项目,而不是一次性加载所有项目。
iOS的此选项的实现正在等待测试,并在treadmill
分支上GitHub问题中描述。
英文:
The Android implementation supports an option called useLazyPreparation which actually defaults to true. This option loads each item just before the player gets up to it in playback rather than upfront all at once.
An implementation of this option for iOS is awaiting testing and is described in this GitHub issue on the treadmill
branch.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论