AudioPlugin.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using UnityEngine;
  2. using UnityEngine.Events;
  3. namespace SC.XR.Unity.Module_DetectorSystem
  4. {
  5. public enum StreamType
  6. {
  7. STREAM_VOICE_CALL = 0,
  8. STREAM_SYSTEM = 1,
  9. STREAM_RING = 2,
  10. STREAM_MUSIC = 3,
  11. STREAM_ALARM = 4
  12. }
  13. public class AudioPlugin
  14. {
  15. private static AudioPlugin instance;
  16. public static AudioPlugin Instance
  17. {
  18. get
  19. {
  20. if (instance == null)
  21. {
  22. if (Application.isEditor)
  23. {
  24. instance = AudioPluginWin.Create();
  25. }
  26. else if (!Application.isEditor && Application.platform == RuntimePlatform.Android)
  27. {
  28. instance = AudioPluginAndroid.Create();
  29. }
  30. else
  31. {
  32. instance = AudioPluginOther.Create();
  33. }
  34. }
  35. return instance;
  36. }
  37. }
  38. public VolumeUnityEvent OnValueChanged = new VolumeUnityEvent();
  39. public virtual void SetType(StreamType type)
  40. {
  41. }
  42. public virtual int GetVolume()
  43. {
  44. return 0;
  45. }
  46. public virtual int GetVolume(int type)
  47. {
  48. return 0;
  49. }
  50. public virtual int GetMaxVolume()
  51. {
  52. return 15;
  53. }
  54. public virtual void SetVolume(int value)
  55. {
  56. }
  57. public virtual void SetVolume(int type, int value)
  58. {
  59. }
  60. /// <summary>
  61. /// 自动去算 或者自己去算
  62. /// </summary>
  63. /// <param name="calu"></param>
  64. public virtual void SetAutoCalu(bool calu)
  65. {
  66. }
  67. }
  68. [System.Serializable]
  69. public class VolumeUnityEvent : UnityEvent<int> { }
  70. }