You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement android.media.SoundPool using GtkMediaStream
This commit is contained in:
@@ -3,10 +3,40 @@ package android.media;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
|
||||
public class SoundPool {
|
||||
|
||||
private long nativePool;
|
||||
|
||||
public interface OnLoadCompleteListener {
|
||||
/**
|
||||
* Called when a sound has completed loading.
|
||||
*
|
||||
* @param soundPool SoundPool object from the load() method
|
||||
* @param soundPool the sample ID of the sound loaded.
|
||||
* @param status the status of the load operation (0 = success)
|
||||
*/
|
||||
public void onLoadComplete(SoundPool soundPool, int sampleId, int status);
|
||||
}
|
||||
|
||||
public SoundPool (int maxStreams, int streamType, int srcQuality) {
|
||||
nativePool = native_constructor();
|
||||
}
|
||||
|
||||
public int load(AssetFileDescriptor afd, int priority) {
|
||||
return 0;
|
||||
return nativeLoad(nativePool, android.os.Environment.getExternalStorageDirectory().getPath() + afd.fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callback hook for the OnLoadCompleteListener.
|
||||
*/
|
||||
public void setOnLoadCompleteListener(OnLoadCompleteListener listener) {
|
||||
System.out.println("WARNING: SoundPool.setOnLoadCompleteListener not implemented yet");
|
||||
}
|
||||
|
||||
public final int play(int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate) {
|
||||
return nativePlay(nativePool, soundID);
|
||||
}
|
||||
|
||||
private static native long native_constructor();
|
||||
private static native int nativeLoad(long nativePool, String path);
|
||||
public static native int nativePlay(long nativePool, int soundID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user