Пример #1
0
        private async Task ReleaseAfterPlayed(AudioPlayer audioPlayer)
        {
            while (audioPlayer.IsPlaying)
            {
                await Task.Yield();
            }

            _audioClipCache.Release(audioPlayer.ClipName);
            _sourcePool.Push(audioPlayer);
        }
Пример #2
0
        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) { }
        }
Пример #3
0
 public IDisposable SetSpriteSingle(Image image, string key)
 {
     SetAloneSprite(image, key);
     return(Disposable.Create(() => { _spriteCache.Release(key); }));
 }