mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
Adding Sound to Android PhoneGap
This commit is contained in:
parent
a32ae0f28a
commit
fca16adf1d
@ -1,10 +1,13 @@
|
||||
package com.nitobi.phonegap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.SensorManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationListener;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Vibrator;
|
||||
@ -86,6 +89,24 @@ public class PhoneGap{
|
||||
});
|
||||
}
|
||||
|
||||
public void playSound(final String filename)
|
||||
{
|
||||
MediaPlayer mp = new MediaPlayer();
|
||||
|
||||
try {
|
||||
mp.setDataSource("file:///android_asset/" + filename);
|
||||
mp.prepare();
|
||||
mp.start();
|
||||
} catch (IllegalArgumentException e) {
|
||||
//TO-DO: Load a Javascript Exception thrower
|
||||
} catch (IllegalStateException e) {
|
||||
//TO-DO: Load a Javascript Exception thrower
|
||||
} catch (IOException e) {
|
||||
//TO-DO: Load a Javascript Exception thrower
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String outputText(){
|
||||
String test = "<p>Test</p>";
|
||||
return test;
|
||||
|
Loading…
Reference in New Issue
Block a user