Exemplo n.º 1
0
 void OnStopped(Entity instanceEntity)
 {
     if (OccupiedInstances.Contains(instanceEntity))
     {
         OccupiedInstances.Remove(instanceEntity);
         if (OccupiedInstances.Count == 0) //it needs all instances to be stopped for the whole AudioUser to be considered stopped.
         {
             OnAudioStopped?.Invoke();
         }
     }
 }
        public override void Stop()
        {
            if (!IsPlaying())
            {
                return;
            }

            _stop(Id);
            _playing = false;
            _paused  = false;
            OnAudioStopped?.Invoke();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 private void BackgroundAudioStopped()
 {
     OnAudioStopped?.Invoke();
 }