public static void PlayMusic(int id) { // stop the current song StopMusic(); // just interrupting the music? if (id == -1) { return; } // check if we have that id UOMusic music = GetMusicById(id); if (music == null) { Logger.Error("Received unknown music id {0}", id); return; } // Console.WriteLine ( "play mp3 file={0} loop={1}", music.Name, music.DoLoop ); // check if the corresponding file exists string path = FileManager.GetFilePath(String.Format("Music\\Digital\\{0}.mp3", music.Name)); if (path == null && !File.Exists(path)) { return; } // play the file InternalPlay(path, music.DoLoop); }
public void StopMusic() { if (_currentMusic != null) { _currentMusic.Stop(); _currentMusic.Dispose(); _currentMusic = null; } }
public void PlayMusic(int music) { if (!_canReproduceAudio) { return; } if (music >= Constants.MAX_MUSIC_DATA_INDEX_COUNT) { return; } float volume; if (CUOEnviroment.Client.Scene is LoginScene) { if (!Settings.GlobalSettings.LoginMusic) { return; } volume = Settings.GlobalSettings.LoginMusicVolume / Constants.SOUND_DELTA; } else { if (ProfileManager.Current == null || !ProfileManager.Current.EnableMusic) { return; } volume = ProfileManager.Current.MusicVolume / Constants.SOUND_DELTA; } if (volume < -1 || volume > 1f) { return; } Sound m = UOFileManager.Sounds.GetMusic(music); if (m == null && _currentMusic != null) { StopMusic(); } else if (m != null && m != _currentMusic) { StopMusic(); _currentMusic = (UOMusic)m; _currentMusic.Play(false, volume: volume); } }
private static UOMusic ParseConfigFile(string line) { string[] splits = line.Split(m_configFileDelimiters); if (splits.Length < 2 || splits.Length > 3) { return(null); } UOMusic ret = new UOMusic(); ret.Id = int.Parse(splits[0]); ret.Name = splits[1]; ret.DoLoop = splits.Length == 3 ? splits[2] == "loop" : false; return(ret); }
public void PlayMusic(int music) { if (music >= Constants.MAX_MUSIC_DATA_INDEX_COUNT) { return; } float volume; if (Engine.SceneManager.CurrentScene is LoginScene) { if (!Engine.GlobalSettings.LoginMusic) { return; } volume = Engine.GlobalSettings.LoginMusicVolume / Constants.SOUND_DELTA; } else { if (Engine.Profile == null || Engine.Profile.Current == null || !Engine.Profile.Current.EnableMusic) { return; } volume = Engine.Profile.Current.MusicVolume / Constants.SOUND_DELTA; } if (volume < -1 || volume > 1f) { return; } Sound m = FileManager.Sounds.GetMusic(music); if (m == null && _currentMusic != null) { StopMusic(); } else if (m != null && m != _currentMusic) { StopMusic(); _currentMusic = (UOMusic)m; _currentMusic.Play(false, volume: volume); } }
static MusicData() { m_songList = new Hashtable(); if (!FileManager.Exists(m_ConfigFilePath)) { return; } StreamReader reader = new StreamReader(FileManager.GetFile(m_ConfigFilePath)); String line; while ((line = reader.ReadLine()) != null) { UOMusic toAdd = ParseConfigFile(line); if (toAdd != null) { m_songList.Add(toAdd.Id, toAdd); } } }
public static void PlaySound(string file) { Profile currentProfile = ProfileManager.CurrentProfile; if (currentProfile == null) { return; } float volume = currentProfile.SoundVolume / Constants.SOUND_DELTA; if (Client.Game.IsActive) { if (!currentProfile.ReproduceSoundsInBackground) { volume = currentProfile.SoundVolume / Constants.SOUND_DELTA; } } else if (!currentProfile.ReproduceSoundsInBackground) { volume = 0; } if (volume < -1 || volume > 1f) { return; } if (!currentProfile.EnableSound || !Client.Game.IsActive && !currentProfile.ReproduceSoundsInBackground) { volume = 0; } try { // full path will be: \UoMarsClient/Music/Digital/UoMars/file.mp3 UOMusic music = new UOMusic(0, "UoMars/" + file, false); music.Play(volume); } catch (Exception e) {} }
public void PlayMusic(int music) { float volume; if (Engine.SceneManager.CurrentScene is LoginScene) { if (!Engine.GlobalSettings.LoginMusic) { return; } volume = Engine.GlobalSettings.LoginMusicVolume / 100f; } else { if (Engine.Profile == null || Engine.Profile.Current == null || !Engine.Profile.Current.EnableMusic) { return; } volume = Engine.Profile.Current.MusicVolume / 100f; } if (volume < 0.01f || volume > 1f) { return; } Sound m = FileManager.Sounds.GetMusic(music); if (m == null && _currentMusic != null) { StopMusic(); } else if (m != null && m != _currentMusic) { StopMusic(); _currentMusic = (UOMusic)m; _currentMusic.Play(false, volume: volume); } }
private static UOMusic ParseConfigFile(string line) { string[] splits = line.Split ( m_configFileDelimiters ); if (splits.Length < 2 || splits.Length > 3) { return null; } UOMusic ret = new UOMusic(); ret.Id = int.Parse ( splits[0] ); ret.Name = splits[1]; ret.DoLoop = splits.Length == 3 ? splits[2] == "loop" : false; return ret; }