예제 #1
0
        public void SwapProvisionalClip(AudioMateClip provisionalClip, AudioMateClip audioMateClip)
        {
            var index = _clips.IndexOf(provisionalClip);

            _clips.Remove(provisionalClip);
            _clips.Insert(index, audioMateClip);
        }
예제 #2
0
 /**
  * Adds a clip to the active collections
  */
 public void AddClipToActiveCollection(AudioMateClip clip, bool noEvent = false)
 {
     ActiveCollection?.Add(clip);
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
 }
예제 #3
0
 /**
  * Removes a clip from a collection
  */
 public bool RemoveClipFromActiveCollection(AudioMateClip clip, bool noEvent = false)
 {
     if (ActiveCollection == null || !ActiveCollection.Remove(clip))
     {
         return(false);
     }
     if (!noEvent)
     {
         OnActiveCollectionUpdated.Invoke();
     }
     return(true);
 }
예제 #4
0
 /**
  * Adds a clip to this collections
  */
 public void Add(AudioMateClip clip)
 {
     if (_clips == null)
     {
         return;
     }
     if (_clips.Contains(clip))
     {
         return;
     }
     _clips.Add(clip);
     ResetUnplayedClips();
 }
예제 #5
0
        /**
         * Removes a clip from this collection
         */
        public bool Remove(AudioMateClip clip)
        {
            if (_clips == null)
            {
                return(false);
            }
            var result = _clips.Remove(clip);

            if (result)
            {
                ResetUnplayedClips();
            }
            return(result);
        }
예제 #6
0
        public bool Parse(JSONNode jn)
        {
            try
            {
                if (jn == null || jn.AsObject == null)
                {
                    SuperController.LogMessage($"AudioMate.{nameof(AudioMateClipCollection)}.{nameof(Parse)} param jn is null");
                    return(false);
                }

                _clips.Clear();
                Name                 = jn["name"];
                Enabled              = jn["enabled"].AsBool;
                ReceiverAtom         = jn["receiverAtom"];
                ReceiverNode         = jn["receiverNode"];
                ShuffleMode          = jn["shuffle"].AsBool;
                AlwaysQueue          = jn["alwaysQueue"].AsBool;
                OnlyIfClear          = jn["onlyIfClear"].AsBool;
                PlayChance           = jn["playChance"].AsFloat;
                _lastPlayedClipIndex = jn["lastClipIndex"].AsInt;
                if (jn["clips"] != null)
                {
                    foreach (JSONClass clip in jn["clips"].AsArray)
                    {
                        var provisionalClip = new AudioMateClip(clip)
                        {
                            IsProvisional = true
                        };
                        _clips.Add(provisionalClip);
                    }
                }
                ResetUnplayedClips();
                Init();
            }
            catch (Exception e)
            {
                SuperController.LogError($"AudioMate.{nameof(AudioMateClipCollection)}.{nameof(Parse)} {e}");
                return(false);
            }
            return(true);
        }
예제 #7
0
 public bool Contains(AudioMateClip clip) => (bool)_clips.Contains(clip);