Skip to content

Commit

Permalink
playback: re-add file playback
Browse files Browse the repository at this point in the history
  • Loading branch information
OxygenCobalt committed Jan 12, 2025
1 parent 08e09af commit ad4b9a3
Showing 1 changed file with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.oxycblt.auxio.playback.service
import android.content.Context
import android.content.Intent
import android.media.audiofx.AudioEffect
import android.provider.OpenableColumns
import androidx.media3.common.AudioAttributes
import androidx.media3.common.C
import androidx.media3.common.MediaItem
Expand Down Expand Up @@ -181,13 +182,34 @@ class ExoPlaybackStateHolder(
// Open -> Try to find the Song for the given file and then play it from all songs
is DeferredPlayback.Open -> {
L.d("Opening specified file")
// library.findSongForUri(context, action.uri)?.let { song ->
// playbackManager.play(
// requireNotNull(commandFactory.song(song,
// ShuffleMode.IMPLICIT)) {
// "Invalid playback parameters"
// })
// }
context.applicationContext.contentResolver
.query(
action.uri,
arrayOf(OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE),
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)
}
}
}
}
}

Expand Down

0 comments on commit ad4b9a3

Please sign in to comment.