public void PutInPool(PYAudioSource data) { if (_poolAudioSource.Contains(data)) { return; } StartCoroutine(PutInPoolRoutine(data)); }
public void Stop(PYAudioTags audio, float fadeDuration) { PYAudioSource source = GetPYAudioSource(audio); if (source == null) { return; } source.Stop(fadeDuration); }
public void Resume(PYAudioTags audio) { PYAudioSource audioSource = GetPYAudioSource(audio); if (audioSource == null) { return; } audioSource.Resume(); }
public void Stop(PYAudioTags audio) { PYAudioSource audioSource = GetPYAudioSource(audio); if (audioSource == null) { return; } audioSource.Stop(); }
private PYAudioSource StartBundleAudioClip(AudioClip audioClip, PYAudioTags audioTag, PYGroupTag group) { PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource != null && audioSource.Track.GroupTag == PYGroupTag.Voice) { return(audioSource); } return(StartAudio(audioTag, new AudioTrack(group, audioClip))); }
/// <summary> /// Use this to play audios from a specific bundleManager /// </summary> /// <param name="bundleManager">From which bundleManager the audio will be fetch</param> /// <param name="audioTag">Use PYAudioTags that start with a B_</param> /// <param name="group">In which group/channel this audio will be played</param> /// <returns></returns> public PYAudioSource StartAudio(PYBundleSubManager bundleManager, PYAudioTags audioTag, PYGroupTag group) { PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource != null && audioSource.Track.GroupTag == PYGroupTag.Voice) { return(audioSource); } return(StartAudio(audioTag, new AudioTrack(group, bundleManager.GetAsset <AudioClip>(audioTag.ToString().Replace("B_", ""))))); }
private System.Collections.IEnumerator PutInPoolRoutine(PYAudioSource data) { yield return(new WaitForEndOfFrame()); if (data.IsPlaying || data.IsPaused) { data.Stop(); } data.name = "* " + data.name; _executingAudioSources.Remove(data); _poolAudioSource.Enqueue(data); }
/// <summary> /// Use this when you need to play a AudioClip inside a group/channel /// </summary> /// <param name="audioClip">AudioClip to be played</param> /// <param name="group">In which group/channel this audio will be played</param> /// <returns></returns> public PYAudioSource StartAudio(AudioClip audioClip, PYGroupTag group) { PYAudioTags audioTag = (PYAudioTags)ConvertNameToTag(audioClip.name); PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource != null && audioSource.Track.GroupTag == PYGroupTag.Voice) { return(audioSource); } return(StartAudio(audioTag, new AudioTrack(group, audioClip))); }
/// <summary> /// Use this to play Resource audios /// </summary> /// <param name="audioTag">Use PYAudioTags that dont start with a B_</param> /// <returns></returns> public PYAudioSource StartAudio(PYAudioTags audioTag) { PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource != null && audioSource.Track.GroupTag == PYGroupTag.Voice) { return(audioSource); } AudioTrack track = (audioTag == PYAudioTags.None) ? new AudioTrack(audioTag.ToString(), PYGroupTag.Master, string.Empty) : GetAudioTrack(audioTag); return(StartAudio(audioTag, track)); }
public void Play(string name, Action <PYAudioSource.PYAudioSourceEventData> callback) { PYPlayer player = StartAudio(name); PYAudioSource source = player.PYSource; if (source == null) { return; } source.Volume(player.Volume) .Pitch(player.Pitch) .Delay(player.Delay) .Loop(player.Loop).Play(callback); }
public void Play(string name) { PYPlayer player = StartAudio(name); PYAudioSource source = player.PYSource; if (source == null) { return; } source.Volume(player.Volume) .Pitch(player.Pitch) .Delay(player.Delay) .Loop(player.Loop).Play(); }
public PYAudioSource.EventListenerData AddListenerPYAudio(PYAudioTags audioTag, PYAudioSource.EventsType type, Action <PYAudioSource.PYAudioSourceEventData> action) { if (!_audioSourceActions.ContainsKey(audioTag)) { _audioSourceActions.Add(audioTag, new List <PYAudioSource.EventListenerData>()); } _audioSourceActions[audioTag].Add(new PYAudioSource.EventListenerData() { Type = type, Action = action }); // Caso o audio já esteja rodando adicionamos a ação nele PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource) { audioSource.AddListinerToEvent(type, action); } return(_audioSourceActions[audioTag][_audioSourceActions[audioTag].Count - 1]); }
public PYAudioTrigger.Trigger AddTriggerAction(PYAudioTags audioTag, float time, Action action) { if (!_audioTriggers.ContainsKey(audioTag)) { _audioTriggers.Add(audioTag, new List <PYAudioTrigger.Trigger>()); } _audioTriggers[audioTag].Add(new PYAudioTrigger.Trigger() { Time = time, Action = action }); // Caso o audio já esteja rodando adicionamos o trigger nele PYAudioSource audioSource = GetPYAudioSource(audioTag); if (audioSource) { audioSource.AudioTrigger.AddTriggerAction(time, action); } return(_audioTriggers[audioTag][_audioTriggers[audioTag].Count - 1]); }
private PYAudioSource CreatePYAudioSource(string name) { PYAudioSource source = null; if (_poolAudioSource.Count > 0) { source = _poolAudioSource.Dequeue(); } // Verifica pare ter certeza de que o aúdio removido do pool // realmente está parado, antes de reusá-lo, caso ele // ainda esteja sendo utilizado criamos um novo PYAudioSource if (source == null || source.IsPlaying || source.IsPaused) { GameObject clone = new GameObject(); clone.transform.parent = transform; clone.transform.localPosition = Vector3.zero; source = clone.AddComponent <PYAudioSource>(); } source.name = string.Format("PYAudio ({0})", name); return(source); }
// Base method for others implementations private PYAudioSource StartAudio(PYAudioTags audioTag, AudioTrack track) { PYAudioSource audioSource = CreatePYAudioSource(audioTag.ToString()); audioSource.Initialize(audioTag, track); if (_audioTriggers.ContainsKey(audioSource.AudioTag)) { foreach (PYAudioTrigger.Trigger trigger in _audioTriggers[audioSource.AudioTag]) { audioSource.AudioTrigger.AddTriggerAction(trigger); } } if (_audioSourceActions.ContainsKey(audioSource.AudioTag)) { foreach (PYAudioSource.EventListenerData listener in _audioSourceActions[audioSource.AudioTag]) { audioSource.AddListenerToEvent(listener); } } return(audioSource); }
public void AddInExecutingList(PYAudioSource data) { _executingAudioSources.Add(data); }