Esempio n. 1
0
        public void Load(XmlElement xmlNode)
        {
            _musicPacks.Clear();
            foreach (XmlElement xmlPack in xmlNode.GetElementsByTagName(PackDefName))
            {
                var musicPack = new MusicPack();
                musicPack.Load(xmlPack);
                _musicPacks.Add(musicPack.Name, musicPack);

                GameLog.Client.Audio.DebugFormat("adding: musicPack.Name={0}", musicPack.Name);
            }
        }
Esempio n. 2
0
        public void PlayAny(string pack)
        {
            MusicPack musicPack = null;

            if (!_appContext.ThemeMusicLibrary.MusicPacks.TryGetValue(pack, out musicPack))
            {
                _appContext.DefaultMusicLibrary.MusicPacks.TryGetValue(pack, out musicPack);
            }

            if (musicPack != null)
            {
                var track = musicPack.Random();
                PlayFile(track.Value.FileName);
                GameLog.Client.Audio.DebugFormat("PlayAny musicPack={0}, Filename={1}", musicPack.Name, track.Value.FileName);
            }
            else
            {
                GameLog.Client.GameData.WarnFormat("Could not locate music pack \"{0}\".", pack);
            }
        }
Esempio n. 3
0
        public void LoadMusic(MusicPack musicPack, string trackName = null)
        {
            try
            {
                lock (_updateLock)
                {
                    bool play = _isPlaying;
                    Stop();

                    _musicPack = musicPack;

                    if (trackName != null)
                    {
                        _musicEntry = _musicPack.FindByName(trackName);
                    }

                    if (trackName == null || _musicEntry.Value == null)
                    {
                        if (_playMode.HasFlag(PlaybackMode.Random))
                        {
                            _musicEntry = _musicPack.Random();
                        }
                        else if (_playMode.HasFlag(PlaybackMode.Sequential))
                        {
                            _musicEntry = _musicPack.Next();
                        }
                    }

                    if (play && _musicEntry.Value != null)
                    {
                        GameLog.Client.Audio.DebugFormat("called! Trackname: {0}, {1}, playMode={2}", _musicPack.Name, _musicEntry.Value.FileName, _playMode.ToString());
                        Play();
                    }
                }
            }
            catch (Exception e)
            {
                GameLog.Client.Audio.Error(e);
            }
        }