E
E
Eugene2016-02-03 18:07:47
Android
Eugene, 2016-02-03 18:07:47

How to implement control of a third-party music player through your Android application without root?

Task: There is an application with activity, it is necessary that after 60 seconds (Timer and TimerTask are already done) music playback in any player is paused
. I'm only interested in pausing

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
razer89, 2016-02-03
@elisevgeniy

KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PAUSE);
Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
sendOrderedBroadcast(intent, null);

keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PAUSE);
intent = new Intent(Intent.ACTION_MEDIA_BUTTON);
intent.putExtra(Intent.EXTRA_KEY_EVENT, keyEvent);
sendOrderedBroadcast(intent, null);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question