Skip to content

Commit 5f2ea43

Browse files
committed
Make player start quicker
1 parent bedacaa commit 5f2ea43

3 files changed

Lines changed: 23 additions & 33 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ android {
3535
minSdk = 24 // Android 7 - Nougat
3636
targetSdk = 36 // Android 15 Vanilla Ice Cream
3737

38-
versionCode = 123
38+
versionCode = 124
3939
versionName = "5.0-SNAPSHOT"
4040

4141
ndk.abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")

app/src/main/java/org/helllabs/android/xmp/compose/MainNavigation.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,14 @@ fun MainNavigation(
9797
selected = currentBottomBarScreen == destination,
9898
label = { Text(text = destination.title) },
9999
icon = {
100-
if (currentBottomBarScreen == destination) {
101-
Icon(
102-
imageVector = destination.selectedIcon!!,
103-
contentDescription = null
104-
)
105-
} else {
106-
Icon(
107-
imageVector = destination.unSelectedIcon!!,
108-
contentDescription = null
109-
)
110-
}
100+
Icon(
101+
imageVector = if (currentBottomBarScreen == destination) {
102+
destination.selectedIcon!!
103+
} else {
104+
destination.unSelectedIcon!!
105+
},
106+
contentDescription = null
107+
)
111108
},
112109
onClick = {
113110
if (mainBackStack.lastOrNull() != destination) {

app/src/main/java/org/helllabs/android/xmp/service/PlayerService.kt

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -576,23 +576,14 @@ class PlayerService :
576576
return
577577
}
578578

579-
val items = list.mapNotNull { item ->
580-
val modInfo = ModInfo()
581-
if (storageManager.testModule(item, modInfo)) {
582-
val desc = MediaDescriptionCompat.Builder()
583-
.setTitle(modInfo.name.ifEmpty { item.lastPathSegment })
584-
.setMediaUri(item)
585-
.setSubtitle(modInfo.type)
586-
.build()
587-
588-
MediaSessionCompat.QueueItem(desc, desc.hashCode().toLong())
589-
} else {
590-
Timber.w("Item: $item was not a valid module")
591-
null
592-
}
593-
}
594-
595-
playlist.addAll(items)
579+
// Don't test module here, its too slow for a large list.
580+
list.map { uri ->
581+
val desc = MediaDescriptionCompat.Builder()
582+
.setMediaUri(uri)
583+
.build()
584+
585+
MediaSessionCompat.QueueItem(desc, desc.hashCode().toLong())
586+
}.also(playlist::addAll)
596587
}
597588

598589
private fun <T> MutableList<T>.shuffleWithFirst(index: Int) {
@@ -620,8 +611,10 @@ class PlayerService :
620611

621612
// If this file is unrecognized, and we're going backwards, go to previous
622613
// If we're at the start of the list, go to the last recognized file
623-
val isValid =
624-
queueItem.description.mediaUri?.let { storageManager.testModule(it) } ?: false
614+
val modInfo = ModInfo()
615+
val isValid = queueItem.description.mediaUri?.let {
616+
storageManager.testModule(it, modInfo)
617+
} ?: false
625618
if (!isValid) {
626619
Timber.w("$currentFileUri: unrecognized format")
627620
serviceScope.launch {
@@ -724,11 +717,11 @@ class PlayerService :
724717
)
725718
putString(
726719
MediaMetadataCompat.METADATA_KEY_TITLE,
727-
queueItem.description.title.toString()
720+
modInfo.name
728721
)
729722
putString(
730723
MediaMetadataCompat.METADATA_KEY_ARTIST,
731-
queueItem.description.subtitle.toString()
724+
modInfo.type
732725
)
733726
putLong(
734727
MediaMetadataCompat.METADATA_KEY_DURATION,

0 commit comments

Comments
 (0)