Exemple #1
0
        private SoundElement GetSoundElement(CueInfo info, SoundType type)
        {
            // シート取得.
            var soundSheet = GetSoundSheet(info);

            if (soundSheet == null)
            {
                return(null);
            }

            // 再生するキューの名前を指定.
            player.SetCue(soundSheet.Acb, info.Cue);

            // 再生パラメータ設定.
            SetSoundParam(type);

            // セットされた音声データの再生準備を開始.
            var playback = player.Prepare();

            // 再生失敗ならRemovedが返る.
            if (playback.GetStatus() == CriAtomExPlayback.Status.Removed)
            {
                return(null);
            }

            // デフォルトに戻す.
            SetSoundParam();

            var element = new SoundElement(this, type, soundSheet, info, playback);

            return(element);
        }
Exemple #2
0
        /// <summary>
        /// 個別に音量変更.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="value"></param>
        public void SetVolume(SoundElement element, float value)
        {
            player.SetVolume(value);
            player.Update(element.GetPlayback());

            // デフォルトに戻す.
            SetSoundParam();
        }
        /// <summary>
        /// 個別に音量変更.
        /// </summary>
        /// <param name="element"></param>
        /// <param name="value"></param>
        public static void SetVolume(SoundElement element, float value)
        {
            Instance.player.SetVolume(value);
            Instance.player.Update(element.GetPlayback());

            // デフォルトに戻す.
            Instance.SetSoundParam();
        }
Exemple #4
0
        /// <summary>
        /// 個別設定を戻す.
        /// </summary>
        private void ResetSoundParam(SoundElement element)
        {
            SetSoundParam(element.Type);

            player.Update(element.GetPlayback());

            // デフォルトに戻す.
            SetSoundParam();
        }
        /// <summary>
        /// 個別設定を戻す.
        /// </summary>
        private static void ResetSoundParam(SoundElement element)
        {
            Instance.SetSoundParam(element.Type);

            Instance.player.Update(element.GetPlayback());

            // デフォルトに戻す.
            Instance.SetSoundParam();
        }
Exemple #6
0
        private IEnumerator PlaySoundElement(SoundElement element)
        {
            var playback = element.GetPlayback();

            // 再生準備完了待ち.
            while (playback.GetStatus() != CriAtomExPlayback.Status.Playing)
            {
                yield return(null);
            }

            // ポーズを解除.
            playback.Resume(CriAtomEx.ResumeMode.PreparedPlayback);
        }
Exemple #7
0
        /// <summary> サウンド停止 </summary>
        public void Stop(SoundElement element)
        {
            if (element == null)
            {
                return;
            }

            var playback = element.GetPlayback();

            playback.Stop();
            element.Update();

            if (onStop != null)
            {
                onStop.OnNext(element);
            }
        }
Exemple #8
0
        /// <summary> サウンド復帰 </summary>
        public void Resume(SoundElement element, CriAtomEx.ResumeMode resumeMode = CriAtomEx.ResumeMode.AllPlayback)
        {
            if (element == null)
            {
                return;
            }

            var playback = element.GetPlayback();

            playback.Resume(resumeMode);
            element.Update();

            if (onResume != null)
            {
                onResume.OnNext(element);
            }
        }
Exemple #9
0
        /// <summary> サウンド中断 </summary>
        public void Pause(SoundElement element)
        {
            if (element == null)
            {
                return;
            }

            var playback = element.GetPlayback();

            playback.Pause();
            element.Update();

            if (onPause != null)
            {
                onPause.OnNext(element);
            }
        }
        /// <summary> サウンド停止 </summary>
        public static void Stop(SoundElement element, bool ignoresReleaseTime = false)
        {
            if (element == null)
            {
                return;
            }

            var playback = element.GetPlayback();

            playback.Stop(ignoresReleaseTime);
            element.Update();

            if (Instance.onStop != null)
            {
                Instance.onStop.OnNext(element);
            }
        }
Exemple #11
0
        /// <summary>
        ///  ExternalResources内のサウンドを再生.
        /// </summary>
        public SoundElement Play(SoundType type, CueInfo info)
        {
            if (info == null)
            {
                return(null);
            }

            var soundParam = GetSoundParam(type);

            SoundElement element = null;

            if (soundParam.cancelIfPlaying)
            {
                element = FindPlayingElement(type, info);

                if (element != null)
                {
                    return(element);
                }
            }

            element = GetSoundElement(info, type);

            if (element == null)
            {
                return(null);
            }

            // 管理対象に追加.
            soundElements.Add(element);

            // 音量設定.
            SetVolume(element, soundParam.volume);

            Observable.FromCoroutine(() => PlaySoundElement(element)).Subscribe().AddTo(Disposable);

            if (onPlay != null)
            {
                onPlay.OnNext(element);
            }

            return(element);
        }