Skip to content

Commit cce67e1

Browse files
committed
Persistent Playing.
1 parent 5e399e3 commit cce67e1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

app/src/main/java/com/harshRajpurohit/musicPlayer/Music.kt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,10 @@ fun favouriteChecker(id: String): Int{
6464
return -1
6565
}
6666
fun checkPlaylist(playlist: ArrayList<Music>): ArrayList<Music>{
67-
val iter = playlist.iterator()
68-
while(iter.hasNext()){
69-
val music = iter.next()
67+
playlist.forEachIndexed { index, music ->
7068
val file = File(music.path)
7169
if(!file.exists())
72-
playlist.remove(music)
73-
}
74-
// playlist.forEachIndexed { index, music ->
75-
// val file = File(music.path)
76-
// if(!file.exists())
77-
// playlist.removeAt(index)
78-
// }
70+
playlist.removeAt(index)
71+
}
7972
return playlist
8073
}

app/src/main/java/com/harshRajpurohit/musicPlayer/MusicService.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,9 @@ class MusicService: Service(), AudioManager.OnAudioFocusChangeListener {
137137
}
138138
}
139139

140+
//for making persistent
141+
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
142+
return START_STICKY
143+
}
144+
140145
}

0 commit comments

Comments
 (0)