public static void ReloadSound(EventHandler <LoadProgressUpdatedEventArgs> updateEventHandler) { ISoundLoadStrategy resourceLoadStrategy; if (!LoadingWindowViewModel.Settings.SoundIsPackedResource) { resourceLoadStrategy = new FolderLoadStrategy(LoadingWindowViewModel.Settings.SoundFormat); } else { resourceLoadStrategy = new TCDLoadStrategy( LoadingWindowViewModel.Settings.SoundResourceFile, LoadingWindowViewModel.Settings.SoundResourceFilePassword, LoadingWindowViewModel.Settings.SoundResourceFileFormat); } var progressUpdateAction = default(EventHandler <LoadProgressUpdatedEventArgs>); progressUpdateAction = (sender, args) => { updateEventHandler(sender, args); if (args == null) { resourceLoadStrategy.ProgressUpdated -= progressUpdateAction; Application.Current.Dispatcher.Invoke(() => { Constants.SoundEffects.Clear(); var soundEffects = resourceLoadStrategy.GetProvidableFiles(); foreach (var se in soundEffects) { Constants.SoundEffects.Add(se); } Constants.SoundEffects.Add("none"); }); } }; resourceLoadStrategy.ProgressUpdated += progressUpdateAction; resourceLoadStrategy.Load(); Constants.SoundLoadStrategy = resourceLoadStrategy; }
public OpenALAudio(float soundEffectVolume, string tcdFile, string password, string graphicsFormat) { this.audio = AudioEngine.Instance; this.audio.SetVolume(0.5f, OpenALAudio.BGMVolumeGroup); this.audio.SetVolume(soundEffectVolume, OpenALAudio.SEVolumeGroup); this.pianoNotePlayer = new PianoNotePlayer(); var loopPointContents = File.ReadAllText(FilePath, Encoding.GetEncoding("Shift_JIS")); //TODO: this.bgmListAlternate = new List <OggData>(); this.bgmList = loopPointContents.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None) .Where(res => res != string.Empty) .Select(res => ReadOggData(res)).ToList(); this.loadStrategy = new TCDLoadStrategy(tcdFile, password, graphicsFormat); var loadThread = new Thread(new ThreadStart(this.Init)); loadThread.Start(); }