示例#1
0
        public static SoundReference AddSound(string filename)
        {
            if (Sounds.ContainsKey(filename))
            {
                return(Sounds[filename]);
            }

            var rval = new SoundReference(filename);

            Sounds.Add(filename, rval);
            AllSounds.Add(rval);
            Load(rval);
            return(rval);
        }
示例#2
0
        private static void Load(SoundReference reference)
        {
            FileInfo fileinfo = new FileInfo(reference.FileName);

            if (fileinfo == null || !fileinfo.Exists)
            {
                return;
            }

            FileStream stream = fileinfo.OpenRead();

            reference.Sound = SoundEffect.FromStream(stream);
            stream.Close();
        }
示例#3
0
 public MusicEffect(SoundReference sound)
 {
     Music          = sound.CreateInstance();
     Music.IsLooped = true;
 }