Exemple #1
0
        public void Next()
        {
            try
            {
                lock (_updateLock)
                {
                    if (_musicPack == null)
                    {
                        return;
                    }

                    if (_playMode.HasFlag(PlaybackMode.Random))
                    {
                        _musicEntry = _musicPack.Random(_musicEntry.Key);
                    }
                    else if (_playMode.HasFlag(PlaybackMode.Sequential))
                    {
                        _musicEntry = _musicPack.Next(_musicEntry.Key);
                    }

                    GameLog.Client.Audio.DebugFormat("Next at _musicPack={0}, _musicEntry={1}", _musicPack.Name, _musicEntry.Value.FileName);

                    Play();
                }
            }
            catch (Exception e)
            {
                GameLog.Client.Audio.Error(e);
            }
        }
Exemple #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);
            }
        }
Exemple #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);
            }
        }