Merge pull request #24 from PaulWoitaschek:patch-1
PiperOrigin-RevId: 419827570
This commit is contained in:
commit
f06c79e441
@ -87,12 +87,12 @@ class PlaybackService : MediaLibraryService() {
|
|||||||
// Only accept query with pattern "play [Title]" or "[Title]"
|
// Only accept query with pattern "play [Title]" or "[Title]"
|
||||||
// Where [Title]: must be exactly matched
|
// Where [Title]: must be exactly matched
|
||||||
// If no media with exact name found, play a random media instead
|
// If no media with exact name found, play a random media instead
|
||||||
lateinit var mediaTitle: String
|
val mediaTitle =
|
||||||
if (query.lowercase().startsWith("play ")) {
|
if (query.startsWith("play ", ignoreCase = true)) {
|
||||||
mediaTitle = query.subSequence(5, query.length).toString()
|
query.drop(5)
|
||||||
} else {
|
} else {
|
||||||
mediaTitle = query
|
query
|
||||||
}
|
}
|
||||||
|
|
||||||
val item = MediaItemTree.getItemFromTitle(mediaTitle) ?: MediaItemTree.getRandomItem()
|
val item = MediaItemTree.getItemFromTitle(mediaTitle) ?: MediaItemTree.getRandomItem()
|
||||||
player.setMediaItem(item)
|
player.setMediaItem(item)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user