Fixed order of songs in Playlist save

This commit is contained in:
Prathamesh More 2021-11-12 21:14:18 +05:30
parent 5d39ac18dc
commit e216591419

View file

@ -53,7 +53,9 @@ object M3UWriter : M3UConstants {
if (!dir.exists()) dir.mkdirs() if (!dir.exists()) dir.mkdirs()
val fileName = "${playlistWithSongs.playlistEntity.playlistName}.${M3UConstants.EXTENSION}" val fileName = "${playlistWithSongs.playlistEntity.playlistName}.${M3UConstants.EXTENSION}"
val file = File(dir, fileName) val file = File(dir, fileName)
val songs: List<Song> = playlistWithSongs.songs.toSongs() val songs: List<Song> = playlistWithSongs.songs.sortedBy {
it.songPrimaryKey
}.toSongs()
if (songs.isNotEmpty()) { if (songs.isNotEmpty()) {
val bufferedWriter = BufferedWriter(FileWriter(file)) val bufferedWriter = BufferedWriter(FileWriter(file))
bufferedWriter.write(M3UConstants.HEADER) bufferedWriter.write(M3UConstants.HEADER)