79493573

Date: 2025-03-07 22:33:28
Score: 2
Natty:
Report link

Had struggled with this today myself, so in case anyone will have the same problem:

You need to set mediaItem property with current active MediaItem.

As option, inside your AudioHandler add this:

in constructor add:

_listenForDurationChanges
void _listenForDurationChanges() {
    _player.durationStream.listen((duration) {
      final index = _player.currentIndex;
      final newQueue = queue.value;
      if (index == null || newQueue.isEmpty) return;
      final oldMediaItem = newQueue[index];
      final newMediaItem = oldMediaItem.copyWith(duration: duration);
      newQueue[index] = newMediaItem;
      queue.add(newQueue);
      mediaItem.add(newMediaItem) //without this notification will be empty; 
    });
  }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): have the same problem
  • Low reputation (0.5):
Posted by: Artiom