I've tested with three android devices: firetv cube, firetv 4k stick, and pixel xl (phone). Both firetv devices are fire os6, which is equivalent to Android Nougat (Android 7.1.2, level 25). The pixel phone is on Android Pie (API level 28). I pair a bluetooth keyboard to each and use the following keymap:
xml:
<keymap>
<FullscreenVideo>
<keyboard>
<home>SkipPrevious</home>
<end>SkipNext</end>
<PageUp>Previous</PageUp>
<PageDown>Next</PageDown>
<rewind>PlayerControl(Previous)</rewind>
<fastforward>PlayerControl(Next)</fastforward>
</keyboard>
</FullscreenVideo>
</keymap>
On the pixel phone, all three button combinations work as expected in kodi.
On the firetv devices, Next is ignored and Previous results in a rewind to the start of the video. But if I open up youtube, which is simply the youtube running on the silk browser, and open a video playlist, the rewind and fastforward buttons on the keyboard will youtube to jump to the previous or next video. So the os itself can recognize those buttons.
Was the android version of kodi built for a particular android api level? This posting mentions that start with api 26, android's handling of the media button event is different:
https://stackoverflow.com/questions/4596...tons-issue
Quote:In Android 8.0 (API level 26) the handling of media button events is different:
- The handling of media buttons in a UI activity has not changed: foreground activities still get priority in handling media button events.
- If the foreground activity does not handle the media button event, the system routes the event to the app that most recently played audio locally. The active status, flags, and playback state of a media session are not considered when determining which app receives media button events.
- If the app's media session has been released, the system sends the media button event to the app's MediaButtonReceiver if it has one.
- For every other case, the system discards the media button event.
Here is more info on android's guideline on handling media buttons:
https://developer.android.com/guide/topi...diabuttons
Quote:Handling media buttons in an active media session
On Android 5.0 (API level 21) and higher, Android automatically dispatches media button events to your active media session by calling onMediaButtonEvent(). By default this callback translates the KeyEvent into the appropriate media session Callback method that matches the key code.
Prior to Android 5.0 (API level 21), Android handles media button events by broadcasting an intent with the
ACTION_MEDIA_BUTTON action. Your app must register a BroadcastReceiver to intercept these intents. The MediaButtonReceiver class was designed specifically for this purpose. It is a convenience class in the Android media-compat library that handles ACTION_MEDIA_BUTTON and translates the incoming Intents into the appropriate MediaSessionCompat.Callback method calls.
A MediaButtonReceiver is a short-lived BroadcastReceiver. It forwards incoming intents to the service that is managing your media session. If you want to use media buttons in systems earlier than Android 5.0 you must include the MediaButtonReceiver in your manifest with a MEDIA_BUTTON intent filter.:xml:
<receiver android:name="android.support.v4.media.session.MediaButtonReceiver" >
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
In kodi's log, I see entries like this:
Quote:2019-04-26 00:52:32.825 T:12170 DEBUG: CXBMCApp::onReceive - Got intent. Action: android.intent.action.MEDIA_BUTTON
2019-04-26 00:52:32.826 T:12170 INFO: Got MEDIA_BUTTON intent: 88, up:false
2019-04-26 00:52:32.830 T:12288 DEBUG: GetAlbumsByWhereJSON - query took 49 ms
2019-04-26 00:52:32.850 T:12190 DEBUG: Keyboard: scancode: 0x58, sym: 0x00b1, unicode: 0x0000, modifier: 0x0
2019-04-26 00:52:32.850 T:12190 DEBUG: HandleKey: prev_track (0xf0bb) pressed, action is SkipPrevious
2019-04-26 00:52:32.892 T:12270 DEBUG: CVideoPlayer::SetCaching - caching state 2
2019-04-26 00:52:32.892 T:12270 DEBUG: CDVDClock::SetSpeedAdjust - adjusted:0.000000
2019-04-26 00:52:32.892 T:12282 DEBUG: CDVDAudio::Pause - pausing audio stream
2019-04-26 00:52:32.893 T:12270 DEBUG: demuxer seek to: 0.000000
2019-04-26 00:52:32.893 T:12270 DEBUG: SeekTime - unknown position after seek
2019-04-26 00:52:32.893 T:12270 DEBUG: demuxer seek to: 0.000000, success
and
Quote:2019-04-26 00:53:01.863 T:12170 INFO: Got MEDIA_BUTTON intent: 87, up:false
2019-04-26 00:53:01.878 T:12190 DEBUG: Keyboard: scancode: 0x57, sym: 0x00b0, unicode: 0x0000, modifier: 0x0
2019-04-26 00:53:01.878 T:12190 DEBUG: HandleKey: next_track (0xf0ba) pressed, action is SkipNext
2019-04-26 00:53:02.100 T:12170 DEBUG: CXBMCApp::onReceive - Got intent. Action: android.intent.action.MEDIA_BUTTON
The use of
android.intent.action.MEDIA_BUTTON seems to indicate that kodi's media button code is from at most android 5.0 api 21. Perhaps some logic is needed to handle different android versions? But it works on android 9's api 28 so maybe the newest api fixes a compatibility issue in an earlier api?
But I'm not sure why the same issue occurs when mapping to non-media buttons like pageup or home. The underlying code for next/previous may also be affected by different android api levels.
Full debug logs here:
https://paste.kodi.tv/kecifubide.kodi
In this session, I navigate to my Music Videos, view a video, and use each of the six assigned keys three times.