Not quick play when queue become large items
Is your feature request related to a problem? Please describe. There is any ways to make player quick play when large items queue? I have an app fetch song from api as pagination 10 items per page.
For first page or second page 10 or 20 items song there is no concern slow. But when it load items 100 songs up it so slow for play because it waiting for update queue.
I write code in handler as
Future<void> playMusic(final List<MusicModel> list, final int index, {final String playToken = "default" }) async
{
final queue = list.map((e) => e.mediaItem).toList();
await audioHandler.updateQueue(queue);
await audioHandler.skipToQueueItem(index);
}
And code it UI like this maybe great
ListView.builder(
primary: true,
shrinkWrap: true,
itemCount: controller.items.length,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
final item = controller.items[index];
return GestureDetector(
onTap: () {
_player.playMusic(controller.items, index);
// _player.playWithQueue(controller.items, index);
},
child: _itemBuild(item),
);
}
)
Describe the solution you'd like
I have something like
Future<void> playMusic(final List<MusicModel> list, final int index, {final String playToken = "default" }) async
{
final queue = list.map((e) => e.mediaItem).toList();
await audioHandler.playMediaItem(queue[index]);
audioHandler.updateQueue(queue).then((_) {
audioHandler.setCurrentPayingIndex = index;
});
}
Describe alternatives you've considered
Additional context
I had test with
Future<void> playMusic(final List<MusicModel> list, final int index, {final String playToken = "default" }) async
{
final queue = list.map((e) => e.mediaItem).toList();
await audioHandler.playMediaItem(queue[index]);
audioHandler.updateQueue(queue).then((_) {
});
}
It work fine on quick play but when next or prevues item is incorrect.
Please help give me solution or any feedback. Thanks
updateQueue happens instantly. If it is slow, it is purely your implementation of that method that is slow, and if you use other plugins within your implementation of updateQueue, and those plugins are slowing you down, I would suggest opening an issue with those plugins. For example, if you use just_audio's ConcatenatingAudioSource, it doesn't support lazy loading yet on iOS. If that's what you're using, you can either subscribe to that issue or you can avoid concatenating so many items together and implement lazy loading yourself.
I'm facing same issue. DId you find any solution for it? @phuongphally