Exemplo n.º 1
0
        public void Play()
        {
            try
            {
                lock (_updateLock)
                {
                    Stop();
                    _isPlaying = true;

                    if (_musicEntry.Value != null)
                    {
                        _audioTrack = _engine.CreateTrack(
                            ResourceManager.GetResourcePath(_musicEntry.Value.FileName));

                        GameLog.Client.Audio.DebugFormat("called! _musicEntry.Value.FileName: {0}", _musicEntry.Value.FileName);

                        if (_audioTrack != null)
                        {
                            _audioTrack.Group = _channelGroup;
                            _audioTrack.Play(OnTrackEnd);

                            if (_updateTimerSubscription == null)
                            {
                                _updateTimerSubscription = _updateTimer.Subscribe();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                GameLog.Client.Audio.Error(e);
            }
        }
Exemplo n.º 2
0
        public void PlayFile(string fileName)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            var resourcePath = ResourceManager.GetResourcePath(fileName);

            if (!File.Exists(resourcePath))
            {
                GameLog.Client.Audio.WarnFormat($"Could not locate audio file \"{resourcePath}\".");
                return;
            }

            lock (_updateLock)
            {
                var audioTrack = _engine.CreateTrack(resourcePath);
                if (audioTrack != null)
                {
                    audioTrack.Group = _channelGroup;
                    audioTrack.Play(OnTrackEnd);

                    _audioTracks.Add(audioTrack);
                }
            }
        }