示例#1
0
		private void TryLoadData(Stream fileData)
		{
			if ((device as XAudioDevice).XAudio == null)
				return;
			var stream = new MemoryStream();
			fileData.CopyTo(stream);
			stream.Position = 0;
			musicStream = new MusicStreamFactory().Load(stream);
			source = new SourceVoice((device as XAudioDevice).XAudio,
				new WaveFormat(musicStream.Samplerate, 16, musicStream.Channels), false);
		}
		public XnaBufferedMusic(Stream stream)
		{
			musicStream = new MusicStreamFactory().Load(stream);
			var channels = musicStream.Channels == 2 ? AudioChannels.Stereo : AudioChannels.Mono;
			source = new DynamicSoundEffectInstance(musicStream.Samplerate, channels);
		}