Beispiel #1
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;

            lock (_updateLock)
            {
                foreach (var track in _audioTracks)
                {
                    try
                    {
                        track.Stop();
                        track.Dispose();
                    }
                    catch (Exception e)
                    {
                        GameLog.Client.Audio.Error(e);
                    }
                }
                _audioTracks.Clear();

                if (_channelGroup != null)
                {
                    _channelGroup.Dispose();
                    _channelGroup = null;
                }
                _engine = null;
            }
        }
Beispiel #2
0
        public SoundPlayer([NotNull] IAudioEngine engine, [NotNull] IAppContext appContext)
        {
            if (engine == null)
            {
                throw new ArgumentNullException("engine");
            }
            if (appContext == null)
            {
                throw new ArgumentNullException("musicLibrary");
            }

            _engine       = engine;
            _appContext   = appContext;
            _channelGroup = _engine.CreateGrouping("sound");
        }
Beispiel #3
0
        public MusicPlayer([NotNull] IAudioEngine engine, [NotNull] IAppContext appContext)
        {
            if (engine == null)
            {
                throw new ArgumentNullException("engine");
            }
            if (appContext == null)
            {
                throw new ArgumentNullException("appContext");
            }

            _engine       = engine;
            _appContext   = appContext;
            _channelGroup = _engine.CreateGrouping("music");
            _updateTimer  = Observable.Interval(TimeSpan.FromMilliseconds(UpdateInterval), _engine.Scheduler).Do(_ => Update());
        }