You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/06/19 02:31:11 UTC

git commit: [CB-3709] - fixed plugin.xml and references to Media

Updated Branches:
  refs/heads/master a6be9efd1 -> c3ebb3e4f


[CB-3709] - fixed plugin.xml and references to Media


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/c3ebb3e4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/c3ebb3e4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/c3ebb3e4

Branch: refs/heads/master
Commit: c3ebb3e4f883bdc13ee94ce1f27cf4845e222955
Parents: a6be9ef
Author: Tim Kim <ti...@adobe.com>
Authored: Tue Jun 18 17:31:05 2013 -0700
Committer: Tim Kim <ti...@adobe.com>
Committed: Tue Jun 18 17:31:05 2013 -0700

----------------------------------------------------------------------
 plugin.xml                   |  5 ++++-
 src/android/AudioPlayer.java | 31 ++++++++++++++++---------------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c3ebb3e4/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index ab741d2..a9a3398 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -17,12 +17,15 @@ id="org.apache.cordova.core.AudioHandler"
     <!-- android -->
     <platform name="android">
         <config-file target="res/xml/config.xml" parent="/*">
-            <plugin name="Media" value="org.apache.cordova.core.AudioHandler"/>
+            <feature name="Media" >
+                <param name="android-package" value="org.apache.cordova.core.AudioHandler"/>
+            </feature>
         </config-file>
         
         <config-file target="AndroidManifest.xml" parent="/*">
             <uses-permission android:name="android.permission.RECORD_AUDIO" />
             <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
         </config-file>
         
         <source-file src="src/android/AudioHandler.java" target-dir="src/org/apache/cordova/core" />

http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c3ebb3e4/src/android/AudioPlayer.java
----------------------------------------------------------------------
diff --git a/src/android/AudioPlayer.java b/src/android/AudioPlayer.java
index 271dfa3..3df3d01 100644
--- a/src/android/AudioPlayer.java
+++ b/src/android/AudioPlayer.java
@@ -133,7 +133,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         switch (this.mode) {
         case PLAY:
             Log.d(LOG_TAG, "AudioPlayer Error: Can't record in play mode.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
             break;
         case NONE:
             this.audioFile = file;
@@ -151,11 +151,12 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
             } catch (IOException e) {
                 e.printStackTrace();
             }
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
+
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
             break;
         case RECORD:
             Log.d(LOG_TAG, "AudioPlayer Error: Already recording.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
         }
     }
 
@@ -226,7 +227,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         if (this.readyPlayer(this.audioFile)) {
             this.player.seekTo(milliseconds);
             Log.d(LOG_TAG, "Send a onStatus update for the new seek");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + milliseconds / 1000.0f + ");");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + milliseconds / 1000.0f + ");");
         }
         else {
             this.seekOnPrepared = milliseconds;
@@ -245,7 +246,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         }
         else {
             Log.d(LOG_TAG, "AudioPlayer Error: pausePlaying() called during invalid state: " + this.state.ordinal());
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
         }
     }
 
@@ -261,7 +262,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         }
         else {
             Log.d(LOG_TAG, "AudioPlayer Error: stopPlaying() called during invalid state: " + this.state.ordinal());
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_NONE_ACTIVE + "});");
         }
     }
 
@@ -283,7 +284,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
     public long getCurrentPosition() {
         if ((this.state == STATE.MEDIA_RUNNING) || (this.state == STATE.MEDIA_PAUSED)) {
             int curPos = this.player.getCurrentPosition();
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + curPos / 1000.0f + ");");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_POSITION + ", " + curPos / 1000.0f + ");");
             return curPos;
         }
         else {
@@ -362,7 +363,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         this.prepareOnly = true;
 
         // Send status notification to JavaScript
-        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_DURATION + "," + this.duration + ");");
+        this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_DURATION + "," + this.duration + ");");
     }
 
     /**
@@ -390,7 +391,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
         this.player.release();
 
         // Send error notification to JavaScript
-        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', { \"code\":" + arg1 + "});");
+        this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', { \"code\":" + arg1 + "});");
         return false;
     }
 
@@ -401,7 +402,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
      */
     private void setState(STATE state) {
         if (this.state != state) {
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + state.ordinal() + ");");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + state.ordinal() + ");");
         }
         this.state = state;
     }
@@ -414,7 +415,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
     private void setMode(MODE mode) {
         if (this.mode != mode) {
             //mode is not part of the expected behavior, so no notification
-            //this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + mode + ");");
+            //this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_STATE + ", " + mode + ");");
         }
         this.mode = mode;
     }
@@ -450,7 +451,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
             break;
         case RECORD:
             Log.d(LOG_TAG, "AudioPlayer Error: Can't play in record mode.");
-            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
+            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
             return false; //player is not ready
         }
         return true;
@@ -471,7 +472,7 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
                     try {
                         this.loadAudioFile(file);
                     } catch (Exception e) {
-                        this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
+                        this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', "+MEDIA_ERROR+", { \"code\":"+MEDIA_ERR_ABORTED+"});");
                     }
                     return false;
                 case MEDIA_LOADING:
@@ -496,14 +497,14 @@ public class AudioPlayer implements OnCompletionListener, OnPreparedListener, On
                         try {
                             this.loadAudioFile(file);
                         } catch (Exception e) {
-                            this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
+                            this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
                         }
                         //if we had to prepare= the file, we won't be in the correct state for playback
                         return false;
                     }
                 default:
                     Log.d(LOG_TAG, "AudioPlayer Error: startPlaying() called during invalid state: " + this.state);
-                    this.handler.webView.sendJavascript("cordova.require('cordova/plugin/Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
+                    this.handler.webView.sendJavascript("cordova.require('org.apache.cordova.core.AudioHandler.Media').onStatus('" + this.id + "', " + MEDIA_ERROR + ", { \"code\":" + MEDIA_ERR_ABORTED + "});");
             }
         }
         return false;