diff --git a/assets/gap.js b/assets/gap.js index 68e51f16..882d6cd9 100644 --- a/assets/gap.js +++ b/assets/gap.js @@ -196,6 +196,7 @@ var Device = { if (Device.available || Device.whatPlatform == "Android") { try { document.location = "javascript:" + "window.DroidGap." + command + "()"; + alert('document.location=' + document.location); } catch(e) { console.log("Command '" + command + "' has not been executed, because of exception: " + e); alert("Error executing command '" + command + "'.") @@ -213,11 +214,14 @@ var Device = { init: function() { Device.exec("getloc"); + alert('initialized Location function and getloc was called'); }, set: function(lat, lon) { Device.Location.lat = lat; Device.Location.lon = lon; + alert('Device.Location let is' + lat); + alert('Device.Location lon is' + lon); if(Device.Location.callback != null) { Device.Location.callback(lat, lon) Device.Location.callback = null; diff --git a/assets/index.html b/assets/index.html index f3dc1819..45fd8916 100644 --- a/assets/index.html +++ b/assets/index.html @@ -14,7 +14,7 @@ in the format of src=http://hostname:port/iBug.js if you are not using to debug comment out --> - + - +

Main

diff --git a/res/raw/bird.mp3 b/res/raw/bird.mp3 new file mode 100644 index 00000000..9a63a12d Binary files /dev/null and b/res/raw/bird.mp3 differ diff --git a/res/raw/off.mp3 b/res/raw/off.mp3 new file mode 100644 index 00000000..669b8222 Binary files /dev/null and b/res/raw/off.mp3 differ diff --git a/res/raw/on.mp3 b/res/raw/on.mp3 new file mode 100644 index 00000000..ab6759f4 Binary files /dev/null and b/res/raw/on.mp3 differ diff --git a/src/com/nitobi/phonegap/PhoneGap.java b/src/com/nitobi/phonegap/PhoneGap.java index 65b61b4e..7da51543 100644 --- a/src/com/nitobi/phonegap/PhoneGap.java +++ b/src/com/nitobi/phonegap/PhoneGap.java @@ -115,7 +115,53 @@ public class PhoneGap{ MediaPlayer mp = new MediaPlayer(); try { - mp.setDataSource("file:///android_asset/" + filename); + // MediaServer does not allow reading of urls out of app data folder + // thus we grab raw file and submit via file descriptor + // instead + // InputStream is = mCtx.getAssets().open(filename); + // work around cannot play audio streams + // to get around security restriction on MediaPlayer + // until Android sdk 1.1 + // thus these changes and the playSound js + // needs moved to Dev.x so that we can if statement out + // via the sdk number + + if(getSDKVersion() == "1") + { + // The hack way audio stored in R.raw.filename + // and we if statement check our way through + // to match the window.DroidGap.playSound(filename.mp3) + ////call on the html side + + int oursound; + + if (filename == "bird.mp3") { + mp.create(mCtx, R.raw.bird); + + } + if (filename == "on.mp3") { + mp.create(mCtx, R.raw.on); + } + if (filename == "off.mp3"){ + mp.create(mCtx, R.raw.off); + } + } + if(getSDKVersion() == "1.1") + { + //TODO: do right way here when Google fixes it + // as we have a security exception preventing + // playing audio file form file:///android_asset/ location + mp.setDataSource("file:///android_asset/" + filename); + mp.prepare(); + mp.start(); + } + + + + + + //mp.setDataSource("file:///android_asset/" + filename); + //mp.setDataSource("http://ventrix.nsdc.gr/stuff/TERMITES_SKONH.mp3"); mp.prepare(); mp.start(); } catch (IllegalArgumentException e) { @@ -142,16 +188,31 @@ public class PhoneGap{ return uuid; } + public String getModel() + { + String model = android.os.Build.MODEL; + return model; + } + public String getProductName() + { + String productname = android.os.Build.PRODUCT; + return productname; + } + public String getOSVersion() + { + String osversion = android.os.Build.VERSION.RELEASE; + return osversion; + } + public String getSDKVersion() + { + String sdkversion = android.os.Build.VERSION.SDK; + return sdkversion; + } + public String getVersion() { return version; } - public boolean exists() - { - return true; - } - - } diff --git a/src/com/nitobi/phonegap/R.java b/src/com/nitobi/phonegap/R.java index 4bc4cd22..a4fe9f1e 100644 --- a/src/com/nitobi/phonegap/R.java +++ b/src/com/nitobi/phonegap/R.java @@ -14,14 +14,19 @@ public final class R { public static final int icon=0x7f020000; } public static final class id { - public static final int appView=0x7f050000; + public static final int appView=0x7f060000; } public static final class layout { public static final int main=0x7f030000; } + public static final class raw { + public static final int bird=0x7f040000; + public static final int off=0x7f040001; + public static final int on=0x7f040002; + } public static final class string { - public static final int app_name=0x7f040001; - public static final int hello=0x7f040000; - public static final int url=0x7f040002; + public static final int app_name=0x7f050001; + public static final int hello=0x7f050000; + public static final int url=0x7f050002; } }