public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for audio sample."); } using (var fileStream = cache.ContentFileRead(path)) { var stream = new Godot.AudioStreamOGGVorbis() { Data = fileStream.ToArray(), }; if (stream.GetLength() == 0) { throw new InvalidDataException(); } AudioStream = new GodotAudioStreamSource(stream); } }
public override void Load(IResourceCache cache, ResourcePath path) { if (!cache.ContentFileExists(path)) { throw new FileNotFoundException("Content file does not exist for audio sample."); } switch (GameController.Mode) { case GameController.DisplayMode.Headless: AudioStream = new AudioStream(); break; case GameController.DisplayMode.Godot: using (var fileStream = cache.ContentFileRead(path)) { var stream = new Godot.AudioStreamOGGVorbis() { Data = fileStream.ToArray(), }; if (stream.GetLength() == 0) { throw new InvalidDataException(); } AudioStream = new AudioStream(stream); } break; case GameController.DisplayMode.Clyde: using (var fileStream = cache.ContentFileRead(path)) { AudioStream = IoCManager.Resolve <IClyde>().LoadAudioOggVorbis(fileStream); } break; default: throw new ArgumentOutOfRangeException(); } }