Fixed order of songs in Playlist save

main
Prathamesh More 2021-11-12 21:14:18 +05:30
parent 5d39ac18dc
commit e216591419
1 changed files with 3 additions and 1 deletions

View File

@ -53,7 +53,9 @@ object M3UWriter : M3UConstants {
if (!dir.exists()) dir.mkdirs()
val fileName = "${playlistWithSongs.playlistEntity.playlistName}.${M3UConstants.EXTENSION}"
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()) {
val bufferedWriter = BufferedWriter(FileWriter(file))
bufferedWriter.write(M3UConstants.HEADER)