Load large audio files with just_audio

huangapple go评论67阅读模式
英文:

Load large audio files with just_audio

问题

我已经在Flutter中使用just_audiojust_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.

huangapple
  • 本文由 发表于 2023年6月26日 18:59:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76556060.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定