コード例 #1
0
ファイル: VORecorder.cs プロジェクト: neoRiley/XLSound_unity
        void PlayAudioFromPercentage(float p)
        {
            XLSoundUtils.StopAllClips();

            var samples  = XLSoundUtils.GetSampleCount(source.clip);
            var playFrom = Mathf.FloorToInt(samples * p);

            XLSoundUtils.PlayClip(source.clip, playFrom, false);
        }
コード例 #2
0
ファイル: VORecorder.cs プロジェクト: neoRiley/XLSound_unity
        async void ShowPreview(List <VORecorderFrame> list, bool playClip = true)
        {
            isPreviewing = true;
            Queue <VORecorderFrame> frames = GetVOQue(list);
            VORecorderFrame         frame;



            if (playClip)
            {
                nextTexture = voImages[VOPositions.SilentMB];
                await Task.Delay(250);
            }
            else
            {
                frame       = frames.Dequeue();
                nextTexture = voImages[frame.position];
            }

            var  playTime      = DateTime.Now;
            bool didStartAudio = false;

            while (frames.Count > 0)
            {
                frame = frames.Dequeue();
                if (!didStartAudio && playClip)
                {
                    XLSoundUtils.PlayClip(source.clip);
                    didStartAudio = true;
                }
                await Task.Delay(frame.span);

                nextTexture = frame.texture;


                Repaint();
            }

            await Task.Delay(recorder.finalFrameDelay);

            isPreviewing = false;
            nextTexture  = voImages[VOPositions.SilentMB];
        }