using UnityEngine; namespace SC.XR.Unity.Module_DetectorSystem { public class AudioPluginAndroid : AudioPlugin { public static AudioPluginAndroid Create() { return new AudioPluginAndroid(); } private AndroidJavaObject AudioPluginAndroidObject; private AudioUnityListener AudioUnityListener; AudioPluginAndroid() { if (Application.platform == RuntimePlatform.Android) { AudioPluginAndroidObject = new AndroidJavaObject("com.xr.audio.AudioActivity", AndroidPluginBase.CurrentActivity, 3, false); AudioUnityListener = new AudioUnityListener(); AudioPluginAndroidObject.Call("setSoundLister", AudioUnityListener); } } public override void SetType(StreamType type) { AudioPluginAndroidObject.Call("setType", (int)type); } public override int GetVolume() { return AudioPluginAndroidObject.Call("getVolume"); } public override int GetVolume(int type) { return AudioPluginAndroidObject.Call("getVolume", type); } public override int GetMaxVolume() { return AudioPluginAndroidObject.Call("getMaxVolume"); } public override void SetVolume(int value) { AudioPluginAndroidObject.Call("setVolume", value); } public override void SetVolume(int type, int value) { AudioPluginAndroidObject.Call("setVolume", type, value); } /// /// 自动去算 或者自己去算 /// /// public override void SetAutoCalu(bool calu) { AudioPluginAndroidObject.Call("autoCalu", calu); } /// /// 在脚本失活 注销时调用 /// public void UnRegiestAduio() { AudioPluginAndroidObject.Call("unRegistVolue"); } } }