Пример #1
0
        /// <summary>
        /// Creates object of streamed AudioPlayer that can be played on <see cref="DefaultSourceEntity"/>.
        /// </summary>
        /// <param name="name">Name of audio.</param>
        /// <param name="res"><see cref="Stream"/> that contains audio.</param>
        /// <param name="preset"><see cref="AudioPreset"/> that defines different sound properties.</param>
        /// <returns>Object of <see cref="AudioPlayer"/>.</returns>
        public AudioPlayer Create(string name, Stream res, AudioPreset preset)
        {
            AudioPlayer audio = new AudioPlayer(this, name, res, preset);

            _allSounds.Add(audio);

            return(audio);
        }
Пример #2
0
        internal AudioPlayer(AudioEngine audioEngine, string name, Stream res, AudioPreset preset) : this()
        {
            _soundEngine = AudioEngine.SoundEngine;

            FilePath = null;

            _soundSource = _soundEngine.AddSoundSourceFromIOStream(res, name);

            Add(preset, audioEngine.DefaultSourceEntity);
        }
Пример #3
0
        private void Add(AudioPreset preset, Entity entity)
        {
            Flags = preset.Flags;

            Volume          = preset.Volume;
            MinimumDistance = preset.MinimumDistance;

            IsInteriorSound = Flags.HasFlag(AudioFlags.InteriorSound);
            IsExteriorSound = Flags.HasFlag(AudioFlags.ExteriorSound);

            StartFadeIn = Flags.HasFlag(AudioFlags.FadeIn);
            StopFadeOut = Flags.HasFlag(AudioFlags.FadeOut);

            SourceEntity = entity;
        }
Пример #4
0
        internal AudioPlayer(AudioEngine audioEngine, string name, AudioPreset preset) : this()
        {
            _soundEngine = AudioEngine.SoundEngine;

            FileInfo audioInfo = new FileInfo($".\\scripts\\{audioEngine.BaseSoundFolder}/{name}");

            if (audioInfo.Exists == false)
            {
                Screen.ShowSubtitle($"File: {audioInfo.FullName} doesn't exists!");
                return;
            }

            FilePath = audioInfo.FullName;

            _soundEngine.AddSoundSourceFromFile(FilePath);

            Add(preset, audioEngine.DefaultSourceEntity);
        }