Add onMessage(id, data) to plugin API.

A solution was needed to notify the audio player to pause when a phone call comes in. The option was to add a specific onPhone() method or generalize it. Since there are other "events" that are useful to plugins, a generalized solution was used. It is also extensible without changing the plugin API again.

Any plugin can call DroidGap.onMessage() to send a message/event to all other plugins. NetworkManager was updated to send changes in connection status to plugins, so they can intelligently handle lost connections.
This commit is contained in:
Bryce Curtis
2011-11-09 10:34:49 -06:00
parent fd93404c7c
commit 0bbcf5cfd2
10 changed files with 174 additions and 8 deletions
+14 -5
View File
@@ -44,11 +44,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
private static final String LOG_TAG = "AudioPlayer";
// AudioPlayer states
private static int MEDIA_NONE = 0;
private static int MEDIA_STARTING = 1;
private static int MEDIA_RUNNING = 2;
private static int MEDIA_PAUSED = 3;
private static int MEDIA_STOPPED = 4;
public static int MEDIA_NONE = 0;
public static int MEDIA_STARTING = 1;
public static int MEDIA_RUNNING = 2;
public static int MEDIA_PAUSED = 3;
public static int MEDIA_STOPPED = 4;
// AudioPlayer message ids
private static int MEDIA_STATE = 1;
@@ -429,6 +429,15 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
this.state = state;
}
/**
* Get the audio state.
*
* @return int
*/
public int getState() {
return this.state;
}
/**
* Set the volume for audio player