You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/02/28 19:00:55 UTC

android commit: Switching to require syntax for AudioPlayer

Updated Branches:
  refs/heads/master 7c6450de5 -> c00fb987f


Switching to require syntax for AudioPlayer


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/c00fb987
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/c00fb987
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/c00fb987

Branch: refs/heads/master
Commit: c00fb987f63a38ba00b0c91361f5a4b72275f8cf
Parents: 7c6450d
Author: macdonst <si...@gmail.com>
Authored: Tue Feb 28 13:00:33 2012 -0500
Committer: macdonst <si...@gmail.com>
Committed: Tue Feb 28 13:00:33 2012 -0500

----------------------------------------------------------------------
 framework/src/org/apache/cordova/AudioPlayer.java |   26 ++++++++--------
 1 files changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c00fb987/framework/src/org/apache/cordova/AudioPlayer.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/AudioPlayer.java b/framework/src/org/apache/cordova/AudioPlayer.java
index 9f98a33..22b4571 100755
--- a/framework/src/org/apache/cordova/AudioPlayer.java
+++ b/framework/src/org/apache/cordova/AudioPlayer.java
@@ -116,7 +116,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 	public void startRecording(String file) {
 		if (this.mPlayer != null) {
 			Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
 		}
 		
 		// Make sure we're not already recording
@@ -137,11 +137,11 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 			} catch (IOException e) {
 				e.printStackTrace();
 			}
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
 		}
 		else {
 		    Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
 		}
 	}
 	
@@ -183,7 +183,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 	public void startPlaying(String file) {
 		if (this.recorder != null) {
 		    Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");
 		}
 		
 		// If this is a new request to play audio, or stopped
@@ -228,7 +228,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 			} 
 			catch (Exception e) { 
 				e.printStackTrace(); 
-				this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
+				this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
 			}
 		}
 
@@ -242,7 +242,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 			}
 			else {
 			    Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: "+this.state);
-				this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
+				this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_ABORTED+");");			
 			}
 		}
 	} 
@@ -254,7 +254,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 		if (this.mPlayer != null) {
 		    this.mPlayer.seekTo(milliseconds);
 		    Log.d(LOG_TAG, "Send a onStatus update for the new seek");
-		    this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
+		    this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+milliseconds/1000.0f+");");
 		}
 	}
 	
@@ -270,7 +270,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 		}
 		else {
 		    Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: "+this.state);			
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");			
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");			
 		}
 	}
 
@@ -284,7 +284,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 		}
 		else {
 		    Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: "+this.state);			
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");			
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+MEDIA_ERR_NONE_ACTIVE+");");			
 		}
 	}
 	
@@ -305,7 +305,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 	public long getCurrentPosition() {
 		if ((this.state == MEDIA_RUNNING) || (this.state == MEDIA_PAUSED)) {
 		    int curPos = this.mPlayer.getCurrentPosition();
-		    this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
+		    this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_POSITION+", "+curPos/1000.0f+");");
 			return curPos;
 		} 
 		else { 
@@ -384,7 +384,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 		this.prepareOnly = false;
 
 		// Send status notification to JavaScript
-		this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
+		this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_DURATION+","+this.duration+");");
 		
 	}
 
@@ -413,7 +413,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 		this.mPlayer.release();
 		
 		// Send error notification to JavaScript
-		this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
+		this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", "+arg1+");");
 		return false;
 	}
 	
@@ -424,7 +424,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
 	 */
 	private void setState(int state) {
 		if (this.state != state) {
-			this.handler.sendJavascript("Media.onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
+			this.handler.sendJavascript("require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_STATE+", "+state+");");
 		}
 		
 		this.state = state;