コード例 #1
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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;
                }
            }
        }
コード例 #2
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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;
                    }
                }
            }
        }
コード例 #3
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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);
            }
        }
コード例 #4
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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);
            }
        }
コード例 #5
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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;
            }
        }
コード例 #6
0
ファイル: AudioEngine.cs プロジェクト: ermau/Gablarski
        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;
                }
            }
        }