Closed zionnite closed 1 year ago
Hello sir,
After much studying your good works I discovered I was doing it wrong,
what I needed to do was to pass the params to the controller and from there I was able to pass it to the page_manager and then, I was able to add it to the queue, doing it this way it works very well but the issue I have is that,
the moment i comment out _loadPlaylist()
and hotreload, the player will continue to show loading indicator but the Song name is always show but the music will continue to load
message_player Controller
i called the below method inside the initState()
addMessageToPlayer({
required String id,
required String title,
required String album,
required String url,
required String artUri,
}) {
final pageManager = getIt<PageManager>();
pageManager.addMessageToPlayer(
id: id,
title: title,
album: album,
url: url,
artUri: artUri,
);
}
page_manager.dart
inside the Init()
i commented out the _loadPlaylist()
because i don't need it
void init() async {
// await _loadPlaylist();
_listenToPlaybackState();
_listenToCurrentPosition();
_listenToBufferedPosition();
_listenToTotalDuration();
_listenToChangesInSong();
_listenToChangesInPlaylist();
}
Here is the function that adds the items from the controller to the queue
addMessageToPlayer(
{required String id,
required String title,
required String album,
required String url,
required String artUri}) {
// print('ID came ${id}');
// print('TITLE came ${title}');
// print('ALBUM came ${album}');
// print('URL came ${url}');
// print('ARTURL came ${artUri}');
final mediaItem = MediaItem(
id: id,
title: title,
album: album,
extras: {
'url': url,
'artUri': artUri,
},
);
_audioHandler.addQueueItem(mediaItem);
}
Note: If _loadPlaylist()
is not commented out, it will work very well
Please what am i missing?
I was able to solve the issue, what I did was to go inside the addQueueItem
block and add player.setAudioSource(_playlist);
to set the audio player to the latest item
Sorry for my late reply. I'm glad you were able to solve your issue. Thank you for posting the solution for others with the same problem.
Hello sir, trust your day is going well?
pls I have a feature am working on, I list all the audio music in a ListView, and on Item, click pass that item into the MyAudioHandler inside the