You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/06/07 22:20:53 UTC

[8/50] [abbrv] android commit: Merge commit. TABS ARE NOT SPACES

Merge commit. TABS ARE NOT SPACES


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/0ad9ff0d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/0ad9ff0d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/0ad9ff0d

Branch: refs/heads/master
Commit: 0ad9ff0d873cd1e65052336939a144c4777bf9c0
Parents: ca979a9 24e5c24
Author: Joe Bowser <bo...@apache.org>
Authored: Mon Jun 4 15:20:00 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Mon Jun 4 15:20:00 2012 -0700

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AudioPlayer.java  |  103 ++++---
 .../src/org/apache/cordova/ContactAccessor.java    |   33 +-
 .../org/apache/cordova/ContactAccessorSdk5.java    |  246 +++++++++------
 .../src/org/apache/cordova/api/PluginResult.java   |   52 ++--
 4 files changed, 238 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/0ad9ff0d/framework/src/org/apache/cordova/AudioPlayer.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/AudioPlayer.java
index 72efcda,9397ec7..856cc7b
--- a/framework/src/org/apache/cordova/AudioPlayer.java
+++ b/framework/src/org/apache/cordova/AudioPlayer.java
@@@ -37,127 -37,136 +37,136 @@@ import java.io.IOException
   * Only one file can be played or recorded per class instance.
   * 
   * Local audio files must reside in one of two places:
-- * 		android_asset: 		file name must start with /android_asset/sound.mp3
-- * 		sdcard:				file name is just sound.mp3
++ *      android_asset:      file name must start with /android_asset/sound.mp3
++ *      sdcard:             file name is just sound.mp3
   */
  public class AudioPlayer implements OnCompletionListener, OnPreparedListener, OnErrorListener {
  
      private static final String LOG_TAG = "AudioPlayer";
  
      // AudioPlayer states
 -	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;
 -	private static int MEDIA_DURATION = 2;
 +    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;
 +    private static int MEDIA_DURATION = 2;
      private static int MEDIA_POSITION = 3;
 -	private static int MEDIA_ERROR = 9;
 -	
 -	// Media error codes
 +    private static int MEDIA_ERROR = 9;
- 
++    
 +    // Media error codes
-     private static int MEDIA_ERR_NONE_ACTIVE = 0;
-     private static int MEDIA_ERR_ABORTED = 1;
- //    private static int MEDIA_ERR_NETWORK = 2;
- //    private static int MEDIA_ERR_DECODE = 3;
- //    private static int MEDIA_ERR_NONE_SUPPORTED = 4;
- 
-     private AudioHandler handler;					// The AudioHandler object
-     private String id;								// The id of this player (used to identify Media object in JavaScript)
-     private int state = MEDIA_NONE;					// State of recording or playback
-     private String audioFile = null;				// File name to play or record to
-     private float duration = -1;					// Duration of audio
- 
-     private MediaRecorder recorder = null;			// Audio recording object
-     private String tempFile = null;					// Temporary recording file name
- 
-     private MediaPlayer mPlayer = null;				// Audio player object
+     private static int MEDIA_ERR_NONE_ACTIVE    = 0;
+     private static int MEDIA_ERR_ABORTED        = 1;
+     private static int MEDIA_ERR_NETWORK        = 2;
+     private static int MEDIA_ERR_DECODE         = 3;
+     private static int MEDIA_ERR_NONE_SUPPORTED = 4;
 -	
 -	private AudioHandler handler;					// The AudioHandler object
 -	private String id;								// The id of this player (used to identify Media object in JavaScript)
 -	private int state = MEDIA_NONE;					// State of recording or playback
 -	private String audioFile = null;				// File name to play or record to
 -	private float duration = -1;					// Duration of audio
 -
 -	private MediaRecorder recorder = null;			// Audio recording object
 -	private String tempFile = null;					// Temporary recording file name
 -	
 -	private MediaPlayer mPlayer = null;				// Audio player object
 -	private boolean prepareOnly = false;
 -
 -	/**
 -	 * Constructor.
 -	 * 
 -	 * @param handler			The audio handler object
 -	 * @param id				The id of this audio player
 -	 */
 -	public AudioPlayer(AudioHandler handler, String id) {
 -		this.handler = handler;
 -		this.id = id;
++    
++    private AudioHandler handler;                   // The AudioHandler object
++    private String id;                              // The id of this player (used to identify Media object in JavaScript)
++    private int state = MEDIA_NONE;                 // State of recording or playback
++    private String audioFile = null;                // File name to play or record to
++    private float duration = -1;                    // Duration of audio
++
++    private MediaRecorder recorder = null;          // Audio recording object
++    private String tempFile = null;                 // Temporary recording file name
++    
++    private MediaPlayer mPlayer = null;             // Audio player object
 +    private boolean prepareOnly = false;
 +
 +    /**
 +     * Constructor.
 +     * 
-      * @param handler			The audio handler object
-      * @param id				The id of this audio player
++     * @param handler           The audio handler object
++     * @param id                The id of this audio player
 +     */
 +    public AudioPlayer(AudioHandler handler, String id) {
 +        this.handler = handler;
 +        this.id = id;
-         this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
-     }
+         if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+             this.tempFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmprecording.mp3";
+         } else {
+             this.tempFile = "/data/data/" + handler.ctx.getPackageName() + "/cache/tmprecording.mp3";
+         }
 -	}	
 -
 -	/**
 -	 * Destroy player and stop audio playing or recording.
 -	 */
 -	public void destroy() {
 -		
 -		// Stop any play or record
 -		if (this.mPlayer != null) {
 -	        if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 -	            this.mPlayer.stop();
 -	            this.setState(MEDIA_STOPPED);
 -	        }
 -			this.mPlayer.release();
 -			this.mPlayer = null;
 -		}
 -		if (this.recorder != null) {
 -			this.stopRecording();
 -			this.recorder.release();
 -			this.recorder = null;
 -		}
 -	}
 -
 -	/**
 -	 * Start recording the specified file.
 -	 * 
 -	 * @param file				The name of the file
 -	 */
 -	public void startRecording(String file) {
 -		if (this.mPlayer != null) {
 -			Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
 -		}
 -		
 -		// Make sure we're not already recording
 -		else if (this.recorder == null) {
 -			this.audioFile = file;
 -			this.recorder = new MediaRecorder();
 -			this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 -			this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // THREE_GPP);
 -			this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); //AMR_NB);
 -			this.recorder.setOutputFile(this.tempFile);
 -			try {
 -				this.recorder.prepare();
 -				this.recorder.start();
 -				this.setState(MEDIA_RUNNING);
 -				return;
 -			} catch (IllegalStateException e) {
 -				e.printStackTrace();
 -			} catch (IOException e) {
 -				e.printStackTrace();
 -			}
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");			
 -		}
 -		else {
 -		    Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");			
 -		}
 -	}
 -	
 -	/**
 -	 * Save temporary recorded file to specified name
 -	 * 
 -	 * @param file
 -	 */
 -	public void moveFile(String file) {	
 -		/* this is a hack to save the file as the specified name */
 -		File f = new File(this.tempFile);
++    }   
 +
 +    /**
 +     * Destroy player and stop audio playing or recording.
 +     */
 +    public void destroy() {
- 
++        
 +        // Stop any play or record
 +        if (this.mPlayer != null) {
 +            if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 +                this.mPlayer.stop();
 +                this.setState(MEDIA_STOPPED);
 +            }
 +            this.mPlayer.release();
 +            this.mPlayer = null;
 +        }
 +        if (this.recorder != null) {
 +            this.stopRecording();
 +            this.recorder.release();
 +            this.recorder = null;
 +        }
 +    }
 +
 +    /**
 +     * Start recording the specified file.
 +     * 
-      * @param file				The name of the file
++     * @param file              The name of the file
 +     */
 +    public void startRecording(String file) {
 +        if (this.mPlayer != null) {
 +            Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
-             this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
++            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
 +        }
- 
++        
 +        // Make sure we're not already recording
 +        else if (this.recorder == null) {
 +            this.audioFile = file;
 +            this.recorder = new MediaRecorder();
 +            this.recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 +            this.recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT); // THREE_GPP);
 +            this.recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT); //AMR_NB);
 +            this.recorder.setOutputFile(this.tempFile);
 +            try {
 +                this.recorder.prepare();
 +                this.recorder.start();
 +                this.setState(MEDIA_RUNNING);
 +                return;
 +            } catch (IllegalStateException e) {
 +                e.printStackTrace();
 +            } catch (IOException e) {
 +                e.printStackTrace();
 +            }
-             this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
++            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");            
 +        }
 +        else {
 +            Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
-             this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
++            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");            
 +        }
 +    }
- 
++    
 +    /**
 +     * Save temporary recorded file to specified name
 +     * 
 +     * @param file
 +     */
-     public void moveFile(String file) {
- 
++    public void moveFile(String file) { 
 +        /* this is a hack to save the file as the specified name */
 +        File f = new File(this.tempFile);
-         f.renameTo(new File("/sdcard/" + file));
+         if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+             f.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() 
+                     + File.separator + file));
+         } else {
+             f.renameTo(new File("/data/data/" + handler.ctx.getPackageName() + "/cache/" + file));
+         }
 -		
 -	}
 -	
++        
 +    }
- 
++    
      /**
       * Stop recording and save to the file specified when recording started.
       */
@@@ -178,43 -188,43 +187,43 @@@
      /**
       * Start or resume playing audio file.
       * 
--     * @param file				The name of the audio file.
++     * @param file              The name of the audio file.
       */
 -	public void startPlaying(String file) {
 -		if (this.recorder != null) {
 -		    Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
 -		}
 -		
 -		// If this is a new request to play audio, or stopped
 -		else if ((this.mPlayer == null) || (this.state == MEDIA_STOPPED)) {
 -			try {
 -				// If stopped, then reset player
 -				if (this.mPlayer != null) {
 -					this.mPlayer.reset();
 -				}
 -				// Otherwise, create a new one
 -				else {
 -					this.mPlayer = new MediaPlayer();
 -				}
 -				this.audioFile = file;
 -				
 -				// If streaming file
 -				if (this.isStreaming(file)) {
 -					this.mPlayer.setDataSource(file);
 -					this.mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);  
 -					this.setState(MEDIA_STARTING);
 -					this.mPlayer.setOnPreparedListener(this);		
 -					this.mPlayer.prepareAsync();
 -				}
 -				
 -				// If local file
 -				else {
 -					if (file.startsWith("/android_asset/")) {
 -						String f = file.substring(15);
 -						android.content.res.AssetFileDescriptor fd = this.handler.ctx.getBaseContext().getAssets().openFd(f);
 -						this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
 -					}
 +    public void startPlaying(String file) {
 +        if (this.recorder != null) {
 +            Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
 +            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
 +        }
 +
 +        // If this is a new request to play audio, or stopped
 +        else if ((this.mPlayer == null) || (this.state == MEDIA_STOPPED)) {
 +            try {
 +                // If stopped, then reset player
 +                if (this.mPlayer != null) {
 +                    this.mPlayer.reset();
 +                }
 +                // Otherwise, create a new one
 +                else {
 +                    this.mPlayer = new MediaPlayer();
 +                }
 +                this.audioFile = file;
 +
 +                // If streaming file
 +                if (this.isStreaming(file)) {
 +                    this.mPlayer.setDataSource(file);
 +                    this.mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
 +                    this.setState(MEDIA_STARTING);
 +                    this.mPlayer.setOnPreparedListener(this);
 +                    this.mPlayer.prepareAsync();
 +                }
 +
 +                // If local file
 +                else {
 +                    if (file.startsWith("/android_asset/")) {
 +                        String f = file.substring(15);
 +                        android.content.res.AssetFileDescriptor fd = this.handler.ctx.getActivity().getAssets().openFd(f);
 +                        this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
 +                    }
                      else {
                          File fp = new File(file);
                          if (fp.exists()) {
@@@ -283,173 -294,173 +292,173 @@@
      /**
       * Stop playing the audio file.
       */
 -	public void stopPlaying() {
 -		if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 -			this.mPlayer.stop();
 -			this.setState(MEDIA_STOPPED);
 -		}
 -		else {
 -		    Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);			
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_NONE_ACTIVE+"});");			
 -		}
 -	}
 -	
 -	/**
 -	 * Callback to be invoked when playback of a media source has completed.
 -	 * 
 -	 * @param mPlayer			The MediaPlayer that reached the end of the file 
 -	 */
 -	public void onCompletion(MediaPlayer mPlayer) {
 -		this.setState(MEDIA_STOPPED);
 -    } 
 -	
 +    public void stopPlaying() {
 +        if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 +            this.mPlayer.stop();
 +            this.setState(MEDIA_STOPPED);
 +        }
 +        else {
 +            Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: " + this.state);
 +            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
 +        }
 +    }
 +
 +    /**
 +     * Callback to be invoked when playback of a media source has completed.
 +     * 
-      * @param mPlayer			The MediaPlayer that reached the end of the file 
++     * @param mPlayer           The MediaPlayer that reached the end of the file 
 +     */
 +    public void onCompletion(MediaPlayer mPlayer) {
 +        this.setState(MEDIA_STOPPED);
 +    }
 +
      /**
       * Get current position of playback.
       * 
--     * @return 					position in msec or -1 if not playing
++     * @return                  position in msec or -1 if not playing
 +     */
 +    public long getCurrentPosition() {
 +        if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 +            int curPos = this.mPlayer.getCurrentPosition();
 +            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + curPos / 1000.0f + ");");
 +            return curPos;
 +        }
 +        else {
 +            return -1;
 +        }
 +    }
 +
 +    /**
 +     * Determine if playback file is streaming or local.
 +     * It is streaming if file name starts with "http://"
 +     * 
-      * @param file				The file name
-      * @return					T=streaming, F=local
++     * @param file              The file name
++     * @return                  T=streaming, F=local
 +     */
 +    public boolean isStreaming(String file) {
 +        if (file.contains("http://") || file.contains("https://")) {
 +            return true;
 +        }
 +        else {
 +            return false;
 +        }
 +    }
 +
 +    /**
 +      * Get the duration of the audio file.
 +      * 
-       * @param file				The name of the audio file.
-       * @return					The duration in msec.
-       * 							-1=can't be determined
-       * 							-2=not allowed
++      * @param file             The name of the audio file.
++      * @return                 The duration in msec.
++      *                             -1=can't be determined
++      *                             -2=not allowed
 +      */
 +    public float getDuration(String file) {
 +
 +        // Can't get duration of recording
 +        if (this.recorder != null) {
 +            return (-2); // not allowed
 +        }
 +
 +        // If audio file already loaded and started, then return duration
 +        if (this.mPlayer != null) {
 +            return this.duration;
 +        }
 +
 +        // If no player yet, then create one
 +        else {
 +            this.prepareOnly = true;
 +            this.startPlaying(file);
 +
 +            // This will only return value for local, since streaming
 +            // file hasn't been read yet.
 +            return this.duration;
 +        }
 +    }
 +
 +    /**
 +     * Callback to be invoked when the media source is ready for playback. 
 +     * 
-      * @param mPlayer			The MediaPlayer that is ready for playback 
++     * @param mPlayer           The MediaPlayer that is ready for playback 
 +     */
 +    public void onPrepared(MediaPlayer mPlayer) {
 +        // Listen for playback completion
 +        this.mPlayer.setOnCompletionListener(this);
 +
 +        // If start playing after prepared
 +        if (!this.prepareOnly) {
 +
 +            // Start playing
 +            this.mPlayer.start();
 +
 +            // Set player init flag
 +            this.setState(MEDIA_RUNNING);
 +        }
 +
 +        // Save off duration
 +        this.duration = getDurationInSeconds();
 +        this.prepareOnly = false;
 +
 +        // Send status notification to JavaScript
 +        this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_DURATION + "," + this.duration + ");");
 +
 +    }
 +
 +    /**
 +     * By default Android returns the length of audio in mills but we want seconds
 +     * 
 +     * @return length of clip in seconds
       */
 -	public long getCurrentPosition() {
 -		if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 -		    int curPos = this.mPlayer.getCurrentPosition();
 -		    this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
 -			return curPos;
 -		} 
 -		else { 
 -			return -1; 
 -		}
 -	}
 -	
 -	/**
 -	 * Determine if playback file is streaming or local.
 -	 * It is streaming if file name starts with "http://"
 -	 * 
 -	 * @param file				The file name
 -	 * @return					T=streaming, F=local
 -	 */
 -	public boolean isStreaming(String file) {
 -		if (file.contains("http://") || file.contains("https://")) {
 -			return true;
 -		} 
 -		else {
 -			return false;
 -		}
 -	}
 -	
 -   /**
 -     * Get the duration of the audio file.
 +    private float getDurationInSeconds() {
 +        return (this.mPlayer.getDuration() / 1000.0f);
 +    }
 +
 +    /**
 +     * Callback to be invoked when there has been an error during an asynchronous operation
 +     *  (other errors will throw exceptions at method call time).
 +     *  
-      * @param mPlayer			the MediaPlayer the error pertains to
-      * @param arg1				the type of error that has occurred: (MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_SERVER_DIED)
-      * @param arg2				an extra code, specific to the error.
++     * @param mPlayer           the MediaPlayer the error pertains to
++     * @param arg1              the type of error that has occurred: (MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_SERVER_DIED)
++     * @param arg2              an extra code, specific to the error.
 +     */
 +    public boolean onError(MediaPlayer mPlayer, int arg1, int arg2) {
 +        Log.d(LOG_TAG, "AudioPlayer.onError(" + arg1 + ", " + arg2 + ")");
 +
 +        // TODO: Not sure if this needs to be sent?
 +        this.mPlayer.stop();
 +        this.mPlayer.release();
 +
 +        // Send error notification to JavaScript
 +        this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":" + arg1 + "});");
 +        return false;
 +    }
 +
 +    /**
 +     * Set the state and send it to JavaScript.
 +     * 
 +     * @param state
 +     */
 +    private void setState(int state) {
 +        if (this.state != state) {
 +            this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + state + ");");
 +        }
 +
 +        this.state = state;
 +    }
 +
 +    /**
 +     * Get the audio state.
       * 
 -     * @param file				The name of the audio file.
 -     * @return					The duration in msec.
 -     * 							-1=can't be determined
 -     * 							-2=not allowed
 +     * @return int
 +     */
 +    public int getState() {
 +        return this.state;
 +    }
 +
 +    /**
 +     * Set the volume for audio player
 +     *
 +     * @param volume
       */
 -	public float getDuration(String file) {
 -		
 -		// Can't get duration of recording
 -		if (this.recorder != null) {
 -			return(-2); // not allowed
 -		}
 -		
 -		// If audio file already loaded and started, then return duration
 -		if (this.mPlayer != null) {
 -			return this.duration;
 -		}
 -		
 -		// If no player yet, then create one
 -		else {
 -			this.prepareOnly = true;
 -			this.startPlaying(file);
 -			
 -			// This will only return value for local, since streaming
 -			// file hasn't been read yet.
 -			return this.duration;
 -		}
 -	}
 -
 -	/**
 -	 * Callback to be invoked when the media source is ready for playback. 
 -	 * 
 -	 * @param mPlayer			The MediaPlayer that is ready for playback 
 -	 */
 -	public void onPrepared(MediaPlayer mPlayer) {
 -		// Listen for playback completion
 -		this.mPlayer.setOnCompletionListener(this);
 -
 -		// If start playing after prepared
 -		if (!this.prepareOnly) {
 -			
 -			// Start playing
 -			this.mPlayer.start();
 -
 -			// Set player init flag
 -			this.setState(MEDIA_RUNNING);
 -		}
 -		
 -		// Save off duration
 -		this.duration = getDurationInSeconds();	
 -		this.prepareOnly = false;
 -
 -		// Send status notification to JavaScript
 -		this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
 -		
 -	}
 -
 -	/**
 -	 * By default Android returns the length of audio in mills but we want seconds
 -	 * 
 -	 * @return length of clip in seconds
 -	 */
 -	private float getDurationInSeconds() {
 -		return (this.mPlayer.getDuration() / 1000.0f);
 -	}
 -
 -	/**
 -	 * Callback to be invoked when there has been an error during an asynchronous operation
 -	 *  (other errors will throw exceptions at method call time).
 -	 *  
 -	 * @param mPlayer			the MediaPlayer the error pertains to
 -	 * @param arg1				the type of error that has occurred: (MEDIA_ERROR_UNKNOWN, MEDIA_ERROR_SERVER_DIED)
 -	 * @param arg2				an extra code, specific to the error.
 -	 */
 -	public boolean onError(MediaPlayer mPlayer, int arg1, int arg2) {
 -	    Log.d(LOG_TAG, "AudioPlayer.onError(" + arg1 + ", " + arg2+")");
 -
 -		// TODO: Not sure if this needs to be sent?
 -		this.mPlayer.stop();
 -		this.mPlayer.release();
 -		
 -		// Send error notification to JavaScript
 -		this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":"+arg1+"});");
 -		return false;
 -	}
 -	
 -	/**
 -	 * Set the state and send it to JavaScript.
 -	 * 
 -	 * @param state
 -	 */
 -	private void setState(int state) {
 -		if (this.state != state) {
 -			this.handler.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
 -		}
 -		
 -		this.state = state;
 -	}
 -	
 -	/**
 -	 * Get the audio state.
 -	 * 
 -	 * @return int
 -	 */
 -	public int getState() {
 -	    return this.state;
 -	}
 -
 -	/**
 -	 * Set the volume for audio player
 -	 *
 -	 * @param volume
 -	 */
      public void setVolume(float volume) {
          this.mPlayer.setVolume(volume, volume);
      }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/0ad9ff0d/framework/src/org/apache/cordova/ContactAccessor.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/ContactAccessor.java
index 99c375a,d2bf66c..f4ceed1
--- a/framework/src/org/apache/cordova/ContactAccessor.java
+++ b/framework/src/org/apache/cordova/ContactAccessor.java
@@@ -77,9 -75,9 +76,9 @@@ public abstract class ContactAccessor 
                  map.put("urls", true);
                  map.put("photos", true);
                  map.put("categories", true);
-             }
 -            } 
++           } 
              else {
-                 for (int i = 0; i < fields.length(); i++) {
+                 for (int i=0; i<fields.length(); i++) {
                      key = fields.getString(i);
                      if (key.startsWith("displayName")) {
                          map.put("displayName", true);
@@@ -123,7 -121,8 +122,8 @@@
                      }
                  }
              }
-         } catch (JSONException e) {
 -        }
++       }
+         catch (JSONException e) {
              Log.e(LOG_TAG, e.getMessage(), e);
          }
          return map;
@@@ -148,9 -147,10 +148,10 @@@
                      value = null;
                  }
              }
-         } catch (JSONException e) {
 -        }
++       }
+         catch (JSONException e) {
              Log.d(LOG_TAG, "Could not get = " + e.getMessage());
-         }
+         }   
          return value;
      }
  
@@@ -175,8 -175,8 +176,8 @@@
       * Handles removing a contact from the database.
       */
      public abstract boolean remove(String id);
 -  
 -    /**
 +
-     /**
++   /**
       * A class that represents the where clause to be used in the database query 
       */
      class WhereOptions {