i followed this guide The Google Assistant and media apps but the
onPrepareFromSearch() or onPlayFromSearch()
seems to be never called.
Using the Assistant in DHU i see the following logs.
Unable to perform playFromMedia because the mediaId is missing from the MediaItem. Could not execute playFromUri, playFromMediaId or playFromSearch
My implementation is very close to the UMP and i also checked
VLC they both work. I use com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector
The strangest things is, that i can successfully test every capability using media controller test app (Playing by search, play by media id, play by uri, search and play, browse and play)
Using the media controller test app i can also verify that my media is active during voice command. What is also very irritating that pause, play, next and previous works. So the media session is found. Session needs to be set to active.
Any hint would be welcome. Do i need some special registration? There is no default player set in the assistant settings.
This is my onGetRoot. There is no permission check.
override fun onGetRoot(
clientPackageName: String,
clientUid: Int,
rootHints: Bundle?
): BrowserRoot {
val maximumRootChildLimit = rootHints?.getInt(
MediaConstants.BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT,
/* defaultValue= */ 4)
val supportedRootChildFlags = rootHints?.getInt(
MediaConstants.BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_SUPPORTED_FLAGS,
/* defaultValue= */ MediaBrowser.MediaItem.FLAG_BROWSABLE)
val rootExtras = Bundle().apply {
putBoolean(
"android.media.browse.SEARCH_SUPPORTED",
true
)
}
return BrowserRoot(ALBUMS_ROOT, rootExtras)
}
And here is the service in the manifest:
<service
android:name=".service.MediaPlaybackService"
android:exported="true"
android:enabled="true"
tools:ignore="ExportedService"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</service>