diff --git a/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/GL2JNIActivity.java b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/GL2JNIActivity.java index a1558e3..04ac63e 100755 --- a/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/GL2JNIActivity.java +++ b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/GL2JNIActivity.java @@ -20,6 +20,8 @@ import android.view.MotionEvent; public class GL2JNIActivity extends Activity { + + private static GL2JNIActivity instance; GLView mView; @@ -28,7 +30,9 @@ public class GL2JNIActivity extends Activity { super.onCreate(icicle); - + + instance = this; + EngineWrapper.LoadSalmonEngineLibrary(); EngineWrapper.SetActivityInstance(this); EngineWrapper.SetupEnviroment(); @@ -88,4 +92,9 @@ public class GL2JNIActivity extends Activity EngineWrapper.ProcessKeyDown(keyCode, event); return super.onKeyDown(keyCode, event); } + + public static GL2JNIActivity getInstance() { + return instance; + } + } \ No newline at end of file diff --git a/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCalls.java b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCalls.java new file mode 100644 index 0000000..c248e39 --- /dev/null +++ b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCalls.java @@ -0,0 +1,11 @@ +package fishrungames.doublehitballs.sounds; + +public interface JniSoundCalls { + + void playBackgroundSound(); + void stopBackgroundSound(); + + void playGunshotSound(); + void stopGunshotSound(); + +} diff --git a/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCallsImpl.java b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCallsImpl.java new file mode 100644 index 0000000..e5a6b39 --- /dev/null +++ b/proj.android-studio/app/src/main/java/fishrungames/doublehitballs/sounds/JniSoundCallsImpl.java @@ -0,0 +1,47 @@ +package fishrungames.doublehitballs.sounds; + +import android.media.MediaPlayer; + +import fishrungames.doublehitballs.GL2JNIActivity; +import fishrungames.doublehitballs.R; + +/** + * example sounds for JNI calls + * @author Artem Budarin + * Created by Artem Budarin on 06.08.2018. + */ + +public class JniSoundCallsImpl implements JniSoundCalls { + + private MediaPlayer backgroundPlayer = null; + private MediaPlayer gunshotPlayer = null; + + @Override + public void playBackgroundSound() { + backgroundPlayer = MediaPlayer.create(GL2JNIActivity.getInstance(), R.raw.background_sound); + backgroundPlayer.setLooping(true); + backgroundPlayer.start(); + } + + @Override + public void stopBackgroundSound() { + if (backgroundPlayer != null) { + backgroundPlayer.stop(); + } + } + + @Override + public void playGunshotSound() { + gunshotPlayer = MediaPlayer.create(GL2JNIActivity.getInstance(), R.raw.gunshot_sound); + gunshotPlayer.setLooping(false); + gunshotPlayer.start(); + } + + @Override + public void stopGunshotSound() { + if (gunshotPlayer != null) { + gunshotPlayer.stop(); + } + } + +} diff --git a/proj.android-studio/app/src/main/res/raw/background_sound.mp3 b/proj.android-studio/app/src/main/res/raw/background_sound.mp3 new file mode 100755 index 0000000..ead9299 Binary files /dev/null and b/proj.android-studio/app/src/main/res/raw/background_sound.mp3 differ diff --git a/proj.android-studio/app/src/main/res/raw/gunshot_sound.mp3 b/proj.android-studio/app/src/main/res/raw/gunshot_sound.mp3 new file mode 100755 index 0000000..ae35066 Binary files /dev/null and b/proj.android-studio/app/src/main/res/raw/gunshot_sound.mp3 differ