public override void Pause() { if (!IsPlaying()) { return; } _pause(Id); _playing = false; _paused = true; OnAudioPaused?.Invoke(); }
protected override void Initialize() { Application.runInBackground = true; if (_unityActivity == null) { AndroidJavaClass unityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); _unityActivity = unityClass.GetStatic <AndroidJavaObject>("currentActivity"); } if (_service == null) { _service = new AndroidJavaClass(PACKAGE_NAME + "." + CLASS_NAME); } _callbackListener = new AndroidBackgroundAudioCallback(); _callbackListener.OnAudioStarted += () => { _playing = true; _paused = false; SetLoop(_looping); SetVolume(_volume); OnAudioStarted?.Invoke(); }; _callbackListener.OnAudioStopped += () => { _playing = false; _paused = false; OnAudioStopped?.Invoke(); }; _callbackListener.OnAudioResumed += () => { _playing = true; _paused = false; OnAudioResumed?.Invoke(); }; _callbackListener.OnAudioPaused += () => { _playing = false; _paused = true; OnAudioPaused?.Invoke(); }; CallOnService("initialize", Id, _callbackListener); }
private void BackgroundAudioPaused() { OnAudioPaused?.Invoke(); }