Example #1
0
        public void Attach(IAudioPlaybackProvider audioPlayback, AudioSource source, AudioEnginePlaybackOptions options)
        {
            if (audioPlayback == null)
            {
                throw new ArgumentNullException("audioPlayback");
            }
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            lock (playbacks)
            {
                if (!this.playbackProviders.Contains(audioPlayback))
                {
                    audioPlayback.SourceFinished += OnSourceFinished;
                    this.playbackProviders.Add(audioPlayback);
                }

                audioPlayback.SetGain(source, options.Gain);
                playbacks[source] = new AudioPlaybackEntity(audioPlayback, source, options);

                if (mutedPlayers.Contains(audioPlayback))
                {
                    playbacks[source].Muted = true;
                }
            }
        }
Example #2
0
        public void Update(AudioSource source, AudioEnginePlaybackOptions options)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            lock (playbacks)
            {
                AudioPlaybackEntity p;
                if (!playbacks.TryGetValue(source, out p))
                {
                    throw new ArgumentException("source is not attached", "source");
                }

                p.AudioPlayback.SetGain(source, options.Gain);
                playbacks[source] = new AudioPlaybackEntity(p.AudioPlayback, source, options);
            }
        }
Example #3
0
        public void Update(AudioSource source, AudioEnginePlaybackOptions options)
        {
            if (source == null)
                throw new ArgumentNullException ("source");
            if (options == null)
                throw new ArgumentNullException ("options");

            lock (playbacks)
            {
                AudioPlaybackEntity p;
                if (!playbacks.TryGetValue (source, out p))
                    throw new ArgumentException ("source is not attached", "source");

                p.AudioPlayback.SetGain (source, options.Gain);
                playbacks[source] = new AudioPlaybackEntity (p.AudioPlayback, source, options);
            }
        }
Example #4
0
        public void Attach(IAudioPlaybackProvider audioPlayback, AudioSource source, AudioEnginePlaybackOptions options)
        {
            if (audioPlayback == null)
                throw new ArgumentNullException ("audioPlayback");
            if (source == null)
                throw new ArgumentNullException ("source");
            if (options == null)
                throw new ArgumentNullException ("options");

            lock (playbacks)
            {
                if (!this.playbackProviders.Contains (audioPlayback))
                {
                    audioPlayback.SourceFinished += OnSourceFinished;
                    this.playbackProviders.Add (audioPlayback);
                }

                audioPlayback.SetGain (source, options.Gain);
                playbacks[source] = new AudioPlaybackEntity (audioPlayback, source, options);

                if (mutedPlayers.Contains (audioPlayback))
                    playbacks[source].Muted = true;
            }
        }
Example #5
0
        public void Attach(IAudioPlaybackProvider audioPlayback, IEnumerable<AudioSource> sources, AudioEnginePlaybackOptions options)
        {
            if (audioPlayback == null)
                throw new ArgumentNullException ("audioPlayback");
            if (sources == null)
                throw new ArgumentNullException ("sources");
            if (options == null)
                throw new ArgumentNullException ("options");

            lock (playbacks)
            {
                if (!this.playbackProviders.Contains (audioPlayback))
                {
                    audioPlayback.SourceFinished += OnSourceFinished;
                    this.playbackProviders.Add (audioPlayback);
                }

                foreach (var s in sources.Where (s => !playbacks.ContainsKey (s) && s.OwnerId != Context.CurrentUser.UserId))
                {
                    audioPlayback.SetGain (s, options.Gain);
                    playbacks[s] = new AudioPlaybackEntity (audioPlayback, s, options);

                    if (mutedPlayers.Contains (audioPlayback))
                        playbacks[s].Muted = true;
                }
            }
        }
Example #6
0
 public AudioPlaybackEntity(IAudioPlaybackProvider audioPlayback, AudioSource source, AudioEnginePlaybackOptions options)
 {
     this.audioPlayback = audioPlayback;
     this.source        = source;
     this.options       = options;
 }
Example #7
0
        public void Attach(IAudioPlaybackProvider audioPlayback, IEnumerable <AudioSource> sources, AudioEnginePlaybackOptions options)
        {
            if (audioPlayback == null)
            {
                throw new ArgumentNullException("audioPlayback");
            }
            if (sources == null)
            {
                throw new ArgumentNullException("sources");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            lock (playbacks)
            {
                if (!this.playbackProviders.Contains(audioPlayback))
                {
                    audioPlayback.SourceFinished += OnSourceFinished;
                    this.playbackProviders.Add(audioPlayback);
                }

                foreach (var s in sources.Where(s => !playbacks.ContainsKey(s) && s.OwnerId != Context.CurrentUser.UserId))
                {
                    audioPlayback.SetGain(s, options.Gain);
                    playbacks[s] = new AudioPlaybackEntity(audioPlayback, s, options);

                    if (mutedPlayers.Contains(audioPlayback))
                    {
                        playbacks[s].Muted = true;
                    }
                }
            }
        }
Example #8
0
 public AudioPlaybackEntity(IAudioPlaybackProvider audioPlayback, AudioSource source, AudioEnginePlaybackOptions options)
 {
     this.audioPlayback = audioPlayback;
     this.source = source;
     this.options = options;
 }