B4A Library [LIB] Control the system media player from your app

Most media players respond to the media keys. This will allow you to send them.

It only has one method, SendMediaButton

Which only has one parameter, which is the media button you want to send:
KeyCodes.KEYCODE_MEDIA_PLAY_PAUSE
KeyCodes.KEYCODE_MEDIA_FAST_FORWARD
KeyCodes.KEYCODE_MEDIA_NEXT
KeyCodes.KEYCODE_MEDIA_PREVIOUS
KeyCodes.KEYCODE_MEDIA_REWIND
KeyCodes.KEYCODE_MEDIA_STOP
 

Attachments

  • MediaController.zip
    2.3 KB · Views: 551

susu

Well-Known Member
Licensed User
Longtime User
Thank you, NeoTechni. Just one question: Can your lib be used in a service?
 

susu

Well-Known Member
Licensed User
Longtime User
Hi Fred, I read about that library already but I forget. Thank you for reminding me.
 

Informatix

Expert
Licensed User
Longtime User
That doesn't seem to transmit keypresses throughout the system, just to the app currently in focus.

As a general rule, you cannot send keys to another app but some keys are intercepted by the system and broadcasted as intents: the Media control keys or the Volume keys for example, so other applications can react to them.
Using the Jondroid library, you can send a "pause" or a "play" action to your current media player with keygenerator(KeyCodes.KEYCODE_MEDIA_PLAY_PAUSE).
 

ibra939

Active Member
Licensed User
Longtime User
thanks wonderful
 
Top