Closed webwayscript closed 4 years ago
Edit Playlist:
Playlist
is immutable. If you want edit playlist, the following methods of PlayerClient
can be used:
insertMusicItem(int position, MusicItem musicItem)
: insert a MusicItem
into the position
of the playlist. If the playlist already contains the MusicItem
, it will be moved to the position
.appendMusicItem(MusicItem musicItem)
: append a MusicItem
to the end of the playlist. If the playlist already contains the MusicItem
, it will be moved to the end of the playlist.moveMusicItem(int fromPosition, int toPosition)
: move the MusicItem
at the fromPosition
in the playlist to the toPosition
.removeMusicItem(MusicItem musicItem)
: removed MusicItem
from the playlist. If the playlist not contains the MusicItem
, this call is ignored.Observe Playlist
changed:
There are two options:
PlayerViewModel
Player.OnPlaylistChangeListener
Example:
// Option 1: use PlayerViewModel
playerViewModel.getPlaylist().observe(lifecycleOwner, new Observer<Playlist>() {
@Override
public void onChanged(Playlist playlist/*fresh playlist*/) {
// ...
}
});
// Option 2: add a Player.OnPlaylistChangeListener
mPlayerClient.addOnPlaylistChangeListener(this, new Player.OnPlaylistChangeListener() {
@Override
public void onPlaylistChanged(PlaylistManager playlistManager, int position) {
// use PlaylistManager to get the fresh playlist
playlistManager.getPlaylist(new PlaylistManager.Callback() {
@Override
public void onFinished(@NonNull Playlist playlist/*fresh playlist*/) {
// ...
}
});
}
});
No . we not talking about add or remove item inside playlist. this one is very interesting.
Now all 4 item playing correctly. Now i add or remove item from json api .. ex now 5 items inside json when i close and reopen app now inside my listview i have 5 items . Bot on click only 4 item playing new item not updated.
after uninstall and reinstall app now only i get 5 items...
i think you need updateplalist() clearplaylist() or something. I dont know inside my listview i saw 5 items ..fmradiomodellist size also 5.. but playing only 4 .. If i removed item from json its not removed inside playlist if i call playerClient.setPlaylist.
i also try with.. not work
`.removeAll(fmradiomodellistok)
.appendAll(fmradiomodellistok)
.build();`
Playlist
is immutable, if your json data modified, you need set a new playlist.
Ok how in My case?
It's up to you. If you want update playlist when json data changed, just use setPlaylist
set a new playlist. If you don't want update playlist, just keep it.
Ok .. Now i understand ... lol it was my mistake Thank you . i need clear my SharedPreferences thank you
If you modify the json data, you should also update the Playlist
. Example: when you add or remove item from json api, you should add or remove it from Playlist
at the same time.
Yes bro thank you its fixed.
If we add extra item inside playlist its not update when open app or setPlaylist. Its playing old play list only .. we need clear playlist before adding setPlaylist. We using like this from arraylist