Difference between revisions of "MediaMonkey for Android dev docs"

From MediaMonkey Wiki
Jump to: navigation, search
(Intents)
(Intents)
Line 15: Line 15:
 
== Intents ==
 
== Intents ==
  
MMA have broadcast receiver to listen intents from external apps/remote devices. Intent must have '''Intent.ACTION_MEDIA_BUTTON''' or '''com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON''' action and external data  '''Intent.EXTRA_KEY_EVENT'''.
+
MMA has a broadcast receiver to listen for intents from external apps/remote devices.  
'''Intent.ACTION_MEDIA_BUTTON''' is common action which also receives other players and is important which player receive it as first.<br />
 
'''com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON''' - this action receives just our app. Same use like '''Intent.ACTION_MEDIA_BUTTON'''. Implemented since 1.1.3.0468.
 
  
 +
Intents must have '''Intent.ACTION_MEDIA_BUTTON''' or '''com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON''' action and external data  '''Intent.EXTRA_KEY_EVENT'''.<br />
 +
Note that '''Intent.ACTION_MEDIA_BUTTON''' is a common action which is also received by other players and it's therefore important which player receives it as first. Alternatively, the '''com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON''' action is received only by MMA, and it's usage is the same as for '''Intent.ACTION_MEDIA_BUTTON''' (Implemented since 1.1.3.0468).
  
  

Revision as of 15:49, 24 August 2015

MediaMonkey for Android Development Documentation

This page contains information for developers who wish to interface with MediaMonkey for Android.


Intents

MMA has a broadcast receiver to listen for intents from external apps/remote devices.

Intents must have Intent.ACTION_MEDIA_BUTTON or com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON action and external data Intent.EXTRA_KEY_EVENT.
Note that Intent.ACTION_MEDIA_BUTTON is a common action which is also received by other players and it's therefore important which player receives it as first. Alternatively, the com.ventismedia.android.mediamonkey.ACTION_MEDIA_BUTTON action is received only by MMA, and it's usage is the same as for Intent.ACTION_MEDIA_BUTTON (Implemented since 1.1.3.0468).


MMA will respond on these key codes:

KeyEvent.KEYCODE_HEADSETHOOK
KeyEvent.KEYCODE_MEDIA_PLAY
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
KeyEvent.KEYCODE_MEDIA_PAUSE
KeyEvent.KEYCODE_MEDIA_NEXT
KeyEvent.KEYCODE_MEDIA_PREVIOUS
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
KeyEvent.KEYCODE_MEDIA_REWIND:
KeyEvent.KEYCODE_MEDIA_STOP:


Examples of use:

Intent intent = new Intent();
intent.setAction("android.intent.action.MEDIA_BUTTON");
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));

getActivity().sendOrderedBroadcast(intent, null);

intent = new Intent();
intent.setAction("android.intent.action.MEDIA_BUTTON");
intent.putExtra(Intent.EXTRA_KEY_EVENT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));

getActivity().sendOrderedBroadcast(intent, null);

Attention: Broadcast should be ordered.