private static IEnumerator _sourceFadeInPlay(AudioSource src, IAudioTrackInfo over, float delay) { if (fading.Contains(src)) { yield break; } fading.Add(src); float t = -delay; src.volume = 0f; for (; t < 0; t += Time.unscaledDeltaTime) { if (over != bgm) { break; } yield return(null); } for (; t < fadeTime; t += Time.unscaledDeltaTime) { if (over != bgm) { break; } src.volume = over.Volume * SaveData.s.BGMVolume * (t / fadeTime); yield return(null); } src.volume = over.Volume * SaveData.s.BGMVolume; fading.Remove(src); }
private static void Assign(AudioSource source, IAudioTrackInfo track) { source.clip = track.Clip; source.volume = track.Volume * SaveData.s.BGMVolume; source.pitch = track.Pitch * pitchMult; source.time = track.StartTime; }
/// <summary> /// Create a copy of the IAudioTrackInfo /// </summary> /// <param name="Track">The IAudioTrackInfo to copy the data from</param> /// <param name="ReadOnly">If true the copy with be read-only</param> public AudioTrackInfo(IAudioTrackInfo Track, bool ReadOnly) : base(Track, ReadOnly) { this.Channels = Track.Channels; this.Bitdepth = Track.Bitdepth; this.SamplingRate = Track.SamplingRate; this.OutputSamplingRate = Track.OutputSamplingRate; }
public void Play(IAudioTrackInfo trackInfo) { this.Log().Info("setting to play: {0}", trackInfo.Uri); BackgroundAudioPlayer.Instance.Track = new AudioTrack(trackInfo.Uri, trackInfo.Title, trackInfo.Artist, "Podcasts", null); BackgroundAudioPlayer.Instance.Play(); }
public void Play(IAudioTrackInfo trackInfo) { throw new NotImplementedException(); //this.Log().Info("setting to play: {0}", trackInfo.Uri); //BackgroundAudioPlayer.Instance.Track = new AudioTrack(trackInfo.Uri, // trackInfo.Title, // trackInfo.Artist, // "Podcasts", // null); //BackgroundAudioPlayer.Instance.Play(); }
public void Play(IAudioTrackInfo trackInfo) { string fileName = "Test.mp3"; var info = Application.GetResourceStream(new Uri("Assets/" + fileName, UriKind.Relative)); using (var iso = IsolatedStorageFile.GetUserStoreForApplication()) { if (!iso.FileExists("/" + fileName)) using (var source = info.Stream) using (var target = iso.CreateFile(fileName)) source.CopyTo(target); } string url = "/" + fileName; BackgroundAudioPlayer.Instance.Track = new AudioTrack(null, trackInfo.Title, trackInfo.Artist, null, trackInfo.AlbumArt, url, EnabledPlayerControls.All); BackgroundAudioPlayer.Instance.Play(); }
private void FadeInPlay(AudioSource src, IAudioTrackInfo over, float delay) { src.PlayDelayed(delay); StartCoroutine(_sourceFadeInPlay(src, over, delay)); }