Updated Branches:
  refs/heads/master 838286df9 -> 5d43835db

CB-446: Enhance setting data source for local files in 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/5d43835d
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/5d43835d
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/5d43835d

Branch: refs/heads/master
Commit: 5d43835db8062575364e7b541d3ee18442cd72af
Parents: 838286d
Author: macdonst <[email protected]>
Authored: Thu Apr 5 13:43:00 2012 -0400
Committer: macdonst <[email protected]>
Committed: Thu Apr 5 13:43:00 2012 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/5d43835d/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 a7ffbee..0bea455 100755
--- a/framework/src/org/apache/cordova/AudioPlayer.java
+++ b/framework/src/org/apache/cordova/AudioPlayer.java
@@ -215,9 +215,15 @@ public class AudioPlayer implements OnCompletionListener, 
OnPreparedListener, On
                                                
android.content.res.AssetFileDescriptor fd = 
this.handler.ctx.getBaseContext().getAssets().openFd(f);
                                                
this.mPlayer.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), 
fd.getLength());
                                        }
-                                       else {
-                                               
this.mPlayer.setDataSource("/sdcard/" + file);
-                                       }
+                    else {
+                        File fp = new File(file);
+                        if (fp.exists()) {
+                            this.mPlayer.setDataSource(file);
+                        } 
+                        else {
+                            this.mPlayer.setDataSource("/sdcard/" + file);
+                        }
+                    }
                                        this.setState(MEDIA_STARTING);
                                        
this.mPlayer.setOnPreparedListener(this);               
                                        this.mPlayer.prepare();

Reply via email to