diff --git a/PlayWallNative/.classpath b/PlayWallNative/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..597b13ce51bb8511e0abd38c46faed73b957d07b --- /dev/null +++ b/PlayWallNative/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="test"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/PlayWallNative/.gitignore b/PlayWallNative/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ae3c1726048cd06b9a143e0376ed46dd9b9a8d53 --- /dev/null +++ b/PlayWallNative/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/PlayWallNative/.project b/PlayWallNative/.project new file mode 100644 index 0000000000000000000000000000000000000000..68507fdf0080728bcd1335ddb47c9170aeb3a493 --- /dev/null +++ b/PlayWallNative/.project @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>PlayWallNative</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/PlayWallNative/.settings/org.eclipse.jdt.core.prefs b/PlayWallNative/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..3a21537071bf4118b9e1ee864cb4bc258aa48211 --- /dev/null +++ b/PlayWallNative/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/PlayWallNative/libNativeAudio.dylib b/PlayWallNative/libNativeAudio.dylib new file mode 100755 index 0000000000000000000000000000000000000000..705cbc2b351f91928644d28ffdf1c1d63ae698fa Binary files /dev/null and b/PlayWallNative/libNativeAudio.dylib differ diff --git a/PlayWallNative/src/de/tobias/playpad/NativeAudio.java b/PlayWallNative/src/de/tobias/playpad/NativeAudio.java new file mode 100644 index 0000000000000000000000000000000000000000..9d391bfaf03232cd510d3b52f4c0173aa4021005 --- /dev/null +++ b/PlayWallNative/src/de/tobias/playpad/NativeAudio.java @@ -0,0 +1,22 @@ +package de.tobias.playpad; + +public class NativeAudio { + + public static native void play(int id); + + public static native void pause(int id); + + public static native void stop(int id); + + public static native double getVolume(int id); + + public static native void setVolume(int id, double volume); + + public static native void load(int id, String path); + + public static native void dispose(int id); + + public static native double getDuration(int id); + + public static native double getPosition(int id); +} diff --git a/PlayWallNative/src/de_tobias_playpad_NativeAudio.h b/PlayWallNative/src/de_tobias_playpad_NativeAudio.h new file mode 100644 index 0000000000000000000000000000000000000000..0d5e2aceb65f7e8b9e449cf64ee1ff29e508c186 --- /dev/null +++ b/PlayWallNative/src/de_tobias_playpad_NativeAudio.h @@ -0,0 +1,85 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class de_tobias_playpad_NativeAudio */ + +#ifndef _Included_de_tobias_playpad_NativeAudio +#define _Included_de_tobias_playpad_NativeAudio +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: de_tobias_playpad_NativeAudio + * Method: play + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_play + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: pause + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_pause + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: stop + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_stop + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getVolume + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getVolume + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: setVolume + * Signature: (ID)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_setVolume + (JNIEnv *, jclass, jint, jdouble); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: load + * Signature: (ILjava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_load + (JNIEnv *, jclass, jint, jstring); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: dispose + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_dispose + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getDuration + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getDuration + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getPosition + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getPosition + (JNIEnv *, jclass, jint); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/PlayWallNative/test/de/tobias/playpad/NativeAudioTest.java b/PlayWallNative/test/de/tobias/playpad/NativeAudioTest.java new file mode 100644 index 0000000000000000000000000000000000000000..42a6d50ae302686c18dcb64be61c120118d03a35 --- /dev/null +++ b/PlayWallNative/test/de/tobias/playpad/NativeAudioTest.java @@ -0,0 +1,20 @@ +package de.tobias.playpad; + +public class NativeAudioTest { + + public static void main(String[] args) { + System.load("/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWallNative/libNativeAudio.dylib"); + + NativeAudio.load(0, "/Users/tobias/Downloads/03%20Hymn%20For%20The%20Weekend.mp3.wav"); + System.out.println(NativeAudio.getDuration(0)); + NativeAudio.play(0); + + while (true) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } +}