incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject [15/16] android commit: CB-446: Enhance setting data source for local files in AudioPlayer
Date Tue, 10 Apr 2012 21:39:21 GMT
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/CordovaWebView
Commit: 5d43835db8062575364e7b541d3ee18442cd72af
Parents: 838286d
Author: macdonst <simon.macdonald@gmail.com>
Authored: Thu Apr 5 13:43:00 2012 -0400
Committer: macdonst <simon.macdonald@gmail.com>
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();


Mime
View raw message