private async Task ReleaseAfterPlayed(AudioPlayer audioPlayer) { while (audioPlayer.IsPlaying) { await Task.Yield(); } _audioClipCache.Release(audioPlayer.ClipName); _sourcePool.Push(audioPlayer); }
private async Task PlayAsync(string path, AudioParameters audioParameters, CancellationToken token) { try { if (_audioPlayer.IsPlaying) { await _audioPlayer.FadeVolume(0, token); } _audioClipCache.Release(_audioPlayer.ClipName); var clip = await _audioClipCache.GetItem(path); token.ThrowIfCancellationRequested(); _audioPlayer.Play(clip, audioParameters); await _audioPlayer.FadeVolume(audioParameters.Volume, token); } catch (OperationCanceledException) { } }
public IDisposable SetSpriteSingle(Image image, string key) { SetAloneSprite(image, key); return(Disposable.Create(() => { _spriteCache.Release(key); })); }