playback: re-add file playback
This commit is contained in:
parent
08e09af5b3
commit
ad4b9a3859
1 changed files with 29 additions and 7 deletions
|
@ -21,6 +21,7 @@ package org.oxycblt.auxio.playback.service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.media.audiofx.AudioEffect
|
import android.media.audiofx.AudioEffect
|
||||||
|
import android.provider.OpenableColumns
|
||||||
import androidx.media3.common.AudioAttributes
|
import androidx.media3.common.AudioAttributes
|
||||||
import androidx.media3.common.C
|
import androidx.media3.common.C
|
||||||
import androidx.media3.common.MediaItem
|
import androidx.media3.common.MediaItem
|
||||||
|
@ -181,13 +182,34 @@ class ExoPlaybackStateHolder(
|
||||||
// Open -> Try to find the Song for the given file and then play it from all songs
|
// Open -> Try to find the Song for the given file and then play it from all songs
|
||||||
is DeferredPlayback.Open -> {
|
is DeferredPlayback.Open -> {
|
||||||
L.d("Opening specified file")
|
L.d("Opening specified file")
|
||||||
// library.findSongForUri(context, action.uri)?.let { song ->
|
context.applicationContext.contentResolver
|
||||||
// playbackManager.play(
|
.query(
|
||||||
// requireNotNull(commandFactory.song(song,
|
action.uri,
|
||||||
// ShuffleMode.IMPLICIT)) {
|
arrayOf(OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE),
|
||||||
// "Invalid playback parameters"
|
null,
|
||||||
// })
|
null,
|
||||||
// }
|
null)
|
||||||
|
?.use { cursor ->
|
||||||
|
val displayNameIndex =
|
||||||
|
cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)
|
||||||
|
val sizeIndex = cursor.getColumnIndexOrThrow(OpenableColumns.SIZE)
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
val displayName = cursor.getString(displayNameIndex)
|
||||||
|
val size = cursor.getLong(sizeIndex)
|
||||||
|
val song =
|
||||||
|
library.songs.find {
|
||||||
|
it.path.name == displayName && it.size == size
|
||||||
|
}
|
||||||
|
if (song != null) {
|
||||||
|
val command =
|
||||||
|
requireNotNull(
|
||||||
|
commandFactory.songFromAll(song, ShuffleMode.IMPLICIT)) {
|
||||||
|
"Invalid playback command"
|
||||||
|
}
|
||||||
|
playbackManager.play(command)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue