Twelve: Add duration to Audio's MediaItem
We can check this w/o the MediaItem being loaded in future queue list
Change-Id: I749341dc6aacbb6532f55bcd2431273edaeebe50
diff --git a/app/src/main/java/org/lineageos/twelve/ext/MediaItem.kt b/app/src/main/java/org/lineageos/twelve/ext/MediaItem.kt
index 052ee57..4611724 100644
--- a/app/src/main/java/org/lineageos/twelve/ext/MediaItem.kt
+++ b/app/src/main/java/org/lineageos/twelve/ext/MediaItem.kt
@@ -8,7 +8,9 @@
import android.net.Uri
import androidx.media3.common.MediaItem
import androidx.media3.common.MediaMetadata
+import androidx.media3.common.util.UnstableApi
+@androidx.annotation.OptIn(UnstableApi::class)
fun buildMediaItem(
title: String,
mediaId: String,
@@ -25,6 +27,7 @@
artworkUri: Uri? = null,
discNumber: Int? = null,
trackNumber: Int? = null,
+ durationMs: Long? = null,
): MediaItem {
val metadata =
MediaMetadata.Builder()
@@ -39,6 +42,7 @@
.setMediaType(mediaType)
.setDiscNumber(discNumber)
.setTrackNumber(trackNumber)
+ .setDurationMs(durationMs)
.build()
return MediaItem.Builder()
diff --git a/app/src/main/java/org/lineageos/twelve/models/Audio.kt b/app/src/main/java/org/lineageos/twelve/models/Audio.kt
index 2ac679b..16d2b93 100644
--- a/app/src/main/java/org/lineageos/twelve/models/Audio.kt
+++ b/app/src/main/java/org/lineageos/twelve/models/Audio.kt
@@ -103,6 +103,7 @@
mimeType = mimeType,
discNumber = discNumber,
trackNumber = trackNumber,
+ durationMs = durationMs.toLong(),
)
companion object {