public void SwapProvisionalClip(AudioMateClip provisionalClip, AudioMateClip audioMateClip) { var index = _clips.IndexOf(provisionalClip); _clips.Remove(provisionalClip); _clips.Insert(index, audioMateClip); }
/** * Adds a clip to the active collections */ public void AddClipToActiveCollection(AudioMateClip clip, bool noEvent = false) { ActiveCollection?.Add(clip); if (!noEvent) { OnActiveCollectionUpdated.Invoke(); } }
/** * 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); }
/** * Adds a clip to this collections */ public void Add(AudioMateClip clip) { if (_clips == null) { return; } if (_clips.Contains(clip)) { return; } _clips.Add(clip); ResetUnplayedClips(); }
/** * 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); }
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); }
public bool Contains(AudioMateClip clip) => (bool)_clips.Contains(clip);