Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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);
            }
        }