12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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<int>("getVolume");
- }
- public override int GetVolume(int type)
- {
- return AudioPluginAndroidObject.Call<int>("getVolume", type);
- }
- public override int GetMaxVolume()
- {
- return AudioPluginAndroidObject.Call<int>("getMaxVolume");
- }
- public override void SetVolume(int value)
- {
- AudioPluginAndroidObject.Call("setVolume", value);
- }
- public override void SetVolume(int type, int value)
- {
- AudioPluginAndroidObject.Call("setVolume", type, value);
- }
- /// <summary>
- /// 自动去算 或者自己去算
- /// </summary>
- /// <param name="calu"></param>
- public override void SetAutoCalu(bool calu)
- {
- AudioPluginAndroidObject.Call("autoCalu", calu);
- }
- /// <summary>
- /// 在脚本失活 注销时调用
- /// </summary>
- public void UnRegiestAduio()
- {
- AudioPluginAndroidObject.Call("unRegistVolue");
- }
- }
- }
|