Ejemplo n.º 1
0
    private void Update()
    {
        if (Microphone.IsRecording(null))
        {
            var   position  = Microphone.GetPosition(null);
            float scend     = position * 1.0f / 44100f;
            var   totalTime = GetTotalTime(mAudioClipList);
            recordTime += Time.deltaTime;
            mRecordTime = totalTime + scend;
        }
        else
        {
            if (mAudioClip.IsNotNull() && mAudioSource.clip.IsNotNull())
            {
                mRecordTime      = mAudioClip.length;
                mTotleTime.Value = (int)mAudioSource.clip.length;
            }
        }

        if (mAudioSource.IsNotNull() && mAudioSource.clip.IsNotNull() && mAudioSource.isPlaying)
        {
            mPlayingTime.Value = (int)mAudioSource.time;
            mTotleTime.Value   = (int)mAudioSource.clip.length;
        }

        if (mAudioSource.IsNotNull() && mAudioSource.clip.IsNotNull())
        {
            mIsPlaying.Value = mAudioSource.isPlaying;
        }
        if (mAudioSource.IsNotNull() && mAudioSource.clip.IsNotNull() && mPlayStatus.Value == PlayStatus.Playing)
        {
            if (mAudioSource.time >= mAudioSource.clip.length)
            {
                mPlayStatus.Value = PlayStatus.Stop;
            }
        }
    }