Open scanetuk opened 4 weeks ago
Here is a start on the Android auto search, pop this into MediaLibrarySessionCallback.kt and it will search your song list:
override fun onSearch(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
query: String,
params: LibraryParams?,
): ListenableFuture<LibraryResult<Void>> {
session.notifySearchResultChanged(
browser,
query,
1,
params
)
return Futures.immediateFuture(LibraryResult.ofVoid(params))
}
override fun onGetSearchResult(
session: MediaLibrarySession,
browser: MediaSession.ControllerInfo,
query: String,
page: Int,
pageSize: Int,
params: LibraryParams?,
): ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> = scope.future(Dispatchers.IO) {
var parentId = "song"
LibraryResult.ofItemList(
when (parentId) {
MusicService.SONG -> database.searchSongs(query, 5).first().map { it.toMediaItem("song") }
else -> when {
else -> emptyList()
}
},
params
)
}
@scanetuk Thanks! Do you expect to search from local database or online?
Maybe to start when searching check local database first to see if the artist/album/song a is downloaded to save on bandwidth and then gets a list of results from online?
@z-huang - I have got the search for any local database song working in Android Auto plus got the Google Search Assistant voice control working to search for any local database song and "next", "stop", "start" etc voice controls working, not sure how the Github works, can you tell me the best way to give you the code? cheers
Great! Please make a pull request.
Checklist
Steps to reproduce the bug
Fantastic app, bug found tried to search in Android Auto
Expected behavior
Search results should appear
Actual behavior
Goes quickley flashes to home screen then to a blank screen as screenshot
Screenshots/Screen recordings
moves to this screen when clicking the magnifying glass
Logs
Looks like it may be because "override fun onSearch" and "override fun onGetSearchResult" are missing from MediaLibrarySessionCallback.kt as hits them when I add them in and do a search in Android Auto, however just learning Java/Kotlin so not sure as yet how to do the search and retreval of search results.
InnerTune version
0.5.7
Android version
Android 13
Additional information
No response