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/04/10 23:39:21 UTC
[15/16] android commit: CB-446: Enhance setting data source for local
files in AudioPlayer
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 <si...@gmail.com>
Authored: Thu Apr 5 13:43:00 2012 -0400
Committer: macdonst <si...@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();