I have list of song on song screen. If user click the one item in the list, I call the loadFirstPlaylist() to load the list of songs(all song in album) into queue and then skip the queue and play. It is working on android but I got following error on iOS. GitHub Sources Code [NowPlaying] [MRNowPlaying] Ignoring setPlaybackState because application does not contain entitlement com.apple.mediaremote.set-playback-state for platform
Future<void> loadFirstPlayList(List<MediaItem> playlist, int index) async {
await emptyPlaylist();
if (playlist.isNotEmpty) {
await _audioHandler.addQueueItems(playlist);
await _audioHandler.skipToQueueItem(index);
await _audioHandler.play();
}
}
Audio Handler Method
@override
Future<void> addQueueItems(List<MediaItem> mediaItems) async {
// manage Just Audio
final audioSource = mediaItems.map(_createAudioSource);
_playlist.addAll(audioSource.toList());
// notify system
final newQueue = queue.value..addAll(mediaItems);
queue.add(newQueue);
}
@override
Future<void> skipToQueueItem(int index) async {
if (index < 0 || index >= queue.value.length) return;
if (_player.shuffleModeEnabled) {
index = _player.shuffleIndices![index];
}
_player.seek(Duration.zero, index: index);
}
@override
Future<void> play() => _player.play();
I do not know if you have figured it out or not already. However, I had the same issue when trying to load an empty playlist. I was following this example, which includes a _loadEmptyPlaylist method. However, when I implemented it this caused the player to fail silently. It now seems to be working by not calling loadAudioSource on an empty audio sequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With