public void jumpInPlayback() { if (preventTrigger == true) { return; } if (audioSource != null) { if (playbackSlider.value < audioSource.clip.length) { audioSource.time = playbackSlider.value; if (audioSource.isPlaying != true) { playButton.sprite = sprPausing; audioSource.Play(); playStatus = PLAY_STATUS.PLAY; } } } else { UnityEngine.Debug.Log("cannot find an audiosource"); } }
public void stopPlaying() //not used.. hmm { audioSource.Stop(); audioSource.time = 0; playbackSlider.value = 0; playStatus = PLAY_STATUS.STOP; //playbackButtonText.text = "Play"; //<--- change to change texture instead of text playButton.sprite = sprPlaying; }
/// <summary> /// [Please do not use it] /// </summary> public void ReleaseLink() { //연결된 Calculate와 연동을 끊는다. if (!_isEndEventCalled) { _parentQueue.OnAnimPlayUnitEnded(this); _isEndEventCalled = true; _playStatus = PLAY_STATUS.End; } }
/// <summary> /// [Please do not use it] Set AnimClip to get data /// </summary> /// <param name="playData"></param> /// <param name="layer"></param> /// <param name="blendMethod"></param> /// <param name="isAutoEndIfNotLoop"></param> /// <param name="isEditor"></param> public void SetAnimClip(apAnimPlayData playData, int layer, BLEND_METHOD blendMethod, bool isAutoEndIfNotLoop, bool isEditor) { _linkedAnimClip = playData._linkedAnimClip; _targetRootUnit = playData._linkedOptRootUnit; //추가 if (_linkedAnimClip._parentPlayUnit != null && _linkedAnimClip._parentPlayUnit != this) { //이미 다른 PlayUnit이 사용중이었다면.. _linkedAnimClip._parentPlayUnit.SetEnd(); //_linkedAnimClip._parentPlayUnit._linkedAnimClip = null; } _linkedAnimClip._parentPlayUnit = this; _layer = layer; _isLoop = _linkedAnimClip.IsLoop; _isAutoEnd = isAutoEndIfNotLoop; if (_isLoop) { _isAutoEnd = false; //<<Loop일때 AutoEnd는 불가능하다 } _blendMethod = blendMethod; _isPause = false; _playStatus = PLAY_STATUS.Ready; _isPlayStartEventCalled = false; _isEndEventCalled = false; //_speedRatio = 1.0f; _isFirstFrame = true; _nextPlayStatus = _playStatus; //추가 1.14 _isResetFrameOnReadyStatus = true; if (isEditor) { _linkedAnimClip.Stop_Editor(false); //Stop은 하되 업데이트는 하지 않는다. (false) } else { _linkedAnimClip.Stop_Opt(false); } _unitWeight = 0.0f; _totalRequestWeights = 0.0f; }
public void playBack() { switch (playStatus) { case PLAY_STATUS.PLAY: //go to pause audioSource.Pause(); playStatus = PLAY_STATUS.PAUSE; //playbackButtonText.text = "Play"; ///change texture! playButton.sprite = sprPlaying; break; case PLAY_STATUS.STOP: //go to play, need initializing case PLAY_STATUS.PAUSE: //go to play, no need of initializing //UnityEngine.Debug.Log("change button text and start playing"); //playbackButtonText.text = "Pause"; //change texture! playButton.sprite = sprPausing; audioSource.Play(); playStatus = PLAY_STATUS.PLAY; break; } }
public void Mecanim_Unlink() { _playStatus = PLAY_STATUS.End; if (_linkedAnimClip != null) { _linkedAnimClip.Stop_Opt(false); _linkedAnimClip._parentPlayUnit = null; _linkedAnimClip = null; } _unitWeight = 0.0f; _totalRequestWeights = 1.0f; _totalRequestWeights = 1.0f; //_isWeightCalculated = true; _isPlayStartEventCalled = false; _mecanimTime = 0.0f; _mecanimTimePrev = 0.0f; _mecanimTimeLength = 1.0f; }
// 메카님 전용 함수 //--------------------------------------------------------------------- public void Mecanim_Link(apAnimClip animClip) { _playStatus = PLAY_STATUS.Play; _linkedAnimClip = animClip; animClip._parentPlayUnit = this; _isPause = false; _isPlayStartEventCalled = false; _isEndEventCalled = false; _isFirstFrame = true; _mecanimTime = 0.0f; _mecanimTimePrev = 0.0f; _mecanimTimeLength = animClip.TimeLength; if (!animClip.IsLoop) { animClip.Stop_Opt(false); } }
/// <summary> /// [Please do not use it] Update Animation /// </summary> /// <param name="tDelta"></param> public void Update(float tDelta) { _tmpIsEnd = false; if (_linkedAnimClip._parentPlayUnit != this) { //PlayUnit이 더이상 이 AnimClip을 제어할 수 없게 되었다 //Link Release를 하고 업데이트도 막는다. ReleaseLink(); return; } PLAY_STATUS requestedNextPlayStatus = _nextPlayStatus; float speedRatio = _linkedAnimClip._speedRatio; switch (_playStatus) { case PLAY_STATUS.Ready: { if (_isFirstFrame) { //_unitWeight = 0.0f; //_prevUnitWeight = 0.0f; _linkedAnimClip.SetPlaying_Opt(false); if (_isResetFrameOnReadyStatus) { _linkedAnimClip.SetFrame_Opt(_linkedAnimClip.StartFrame, false); } _isResetFrameOnReadyStatus = true; //True가 기본값 } } break; case PLAY_STATUS.Play: { if (_isFirstFrame) { //_unitWeight = 1.0f; //_prevUnitWeight = 1.0f; //플레이 시작했다고 알려주자 if (!_isPlayStartEventCalled) { _parentQueue.OnAnimPlayUnitPlayStart(this); _isPlayStartEventCalled = true; } //Debug.Log("Play"); _linkedAnimClip.SetPlaying_Opt(true); } if (!_isPause) { _linkedAnimClip.SetPlaying_Opt(true); _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * speedRatio); } else { _linkedAnimClip.SetPlaying_Opt(false); } } break; case PLAY_STATUS.End: { //아무것도 안합니더 if (_isFirstFrame) { ReleaseLink(); } } break; } if (_tmpIsEnd && _isAutoEnd) { //종료가 되었다면 (일단 Loop는 아니라는 것) //조건에 따라 End로 넘어가자 SetEnd(); } //스테이트 처리 //if(_nextPlayStatus != _playStatus) if (requestedNextPlayStatus != _playStatus) { _playStatus = requestedNextPlayStatus; _nextPlayStatus = _playStatus; _isFirstFrame = true; } else if (_isFirstFrame) { _isFirstFrame = false; } }
private void ChangeNextStatus(PLAY_STATUS nextStatus) { _nextPlayStatus = nextStatus; }
/// <summary> /// [Please do not use it] Update Animation /// </summary> /// <param name="tDelta"></param> public void Update(float tDelta) { //_isUpdated = false; _tmpIsEnd = false; //_unitWeight *= weightCorrectRatio;//<<이거 안해요 if (_linkedAnimClip._parentPlayUnit != this) { //PlayUnit이 더이상 이 AnimClip을 제어할 수 없게 되었다 //Link Release를 하고 업데이트도 막는다. //Debug.LogError("AnimPlayUnit Invalid End"); ReleaseLink(); return; } PLAY_STATUS requestedNextPlayStatus = _nextPlayStatus; switch (_playStatus) { case PLAY_STATUS.Ready: { if (_isFirstFrame) { //_unitWeight = 0.0f; //_prevUnitWeight = 0.0f; _linkedAnimClip.SetPlaying_Opt(false); _linkedAnimClip.SetFrame_Opt(_linkedAnimClip.StartFrame); //Debug.Log("Ready"); } //if (!_isPause) //{ // if (_isDelayIn) // { // //딜레이 후에 플레이된다. // _tDelay += tDelta; // if (_tDelay > _delayToPlayTime) // { // _unitWeight = 0.0f; // _isDelayIn = false; // ChangeNextStatus(PLAY_STATUS.PlayWithFadeIn);//<<플레이 된다. // } // } //} } break; //case PLAY_STATUS.PlayWithFadeIn: // { // if(_isFirstFrame) // { // //_tFade = 0.0f; // //_prevUnitWeight = _unitWeight; // //플레이 시작했다고 알려주자 // if (!_isPlayStartEventCalled) // { // _parentQueue.OnAnimPlayUnitPlayStart(this); // _isPlayStartEventCalled = true; // } // //Debug.Log("Play With Fade In"); // } // if (!_isPause) // { // //_tFade += tDelta; // if (_tFade < _fadeInTime) // { // //_unitWeight = (_prevUnitWeight * (_fadeInTime - _tFade) + 1.0f * _tFade) / _fadeInTime; // _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio); // } // //else // //{ // // _unitWeight = 1.0f; // // //Fade가 끝났으면 Play // // ChangeNextStatus(PLAY_STATUS.Play); // //} // } // } // break; case PLAY_STATUS.Play: { if (_isFirstFrame) { //_unitWeight = 1.0f; //_prevUnitWeight = 1.0f; //플레이 시작했다고 알려주자 if (!_isPlayStartEventCalled) { _parentQueue.OnAnimPlayUnitPlayStart(this); _isPlayStartEventCalled = true; } //Debug.Log("Play"); _linkedAnimClip.SetPlaying_Opt(true); } if (!_isPause) { _linkedAnimClip.SetPlaying_Opt(true); _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio); //_isUpdated = true; //if (_isDelayOut) //{ // //딜레이 후에 FadeOut된다. // _tDelay += tDelta; // if (_tDelay > _delayToEndTime) // { // _isDelayOut = false; // _unitWeight = 1.0f; // ChangeNextStatus(PLAY_STATUS.PlayWithFadeOut);//<<플레이 종료를 위한 FadeOut // } //} } else { _linkedAnimClip.SetPlaying_Opt(false); } } break; //case PLAY_STATUS.PlayWithFadeOut: // { // if(_isFirstFrame) // { // //_tFade = 0.0f; // //_prevUnitWeight = _unitWeight; // //Debug.Log("Play With Fade Out"); // } // if (!_isPause) // { // //_tFade += tDelta; // if (_tFade < _fadeOutTime) // { // //_unitWeight = (_prevUnitWeight * (_fadeOutTime - _tFade) + 0.0f * _tFade) / _fadeOutTime; // _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio); // } // //else // //{ // // _unitWeight = 0.0f; // // ChangeNextStatus(PLAY_STATUS.End); // //} // } // } // break; case PLAY_STATUS.End: { //아무것도 안합니더 if (_isFirstFrame) { //Debug.Log("End"); //_unitWeight = 0.0f; ReleaseLink(); } } break; } if (_tmpIsEnd && _isAutoEnd) { //종료가 되었다면 (일단 Loop는 아니라는 것) //조건에 따라 End로 넘어가자 SetEnd(); } //스테이트 처리 //if(_nextPlayStatus != _playStatus) if (requestedNextPlayStatus != _playStatus) { _playStatus = requestedNextPlayStatus; _nextPlayStatus = _playStatus; _isFirstFrame = true; } else if (_isFirstFrame) { _isFirstFrame = false; } }
/// <summary> /// [Please do not use it] Set AnimClip to get data /// </summary> /// <param name="playData"></param> /// <param name="layer"></param> /// <param name="blendMethod"></param> /// <param name="isAutoEndIfNotLoop"></param> /// <param name="isEditor"></param> public void SetAnimClip(apAnimPlayData playData, int layer, BLEND_METHOD blendMethod, bool isAutoEndIfNotLoop, bool isEditor) { _linkedAnimClip = playData._linkedAnimClip; _targetRootUnit = playData._linkedOptRootUnit; //추가 if (_linkedAnimClip._parentPlayUnit != null && _linkedAnimClip._parentPlayUnit != this) { //이미 다른 PlayUnit이 사용중이었다면.. _linkedAnimClip._parentPlayUnit.SetEnd(); //_linkedAnimClip._parentPlayUnit._linkedAnimClip = null; } _linkedAnimClip._parentPlayUnit = this; _layer = layer; _isLoop = _linkedAnimClip.IsLoop; _isAutoEnd = isAutoEndIfNotLoop; if (_isLoop) { _isAutoEnd = false; //<<Loop일때 AutoEnd는 불가능하다 } _blendMethod = blendMethod; _isPause = false; _playStatus = PLAY_STATUS.Ready; _isPlayStartEventCalled = false; _isEndEventCalled = false; //_fadeInTime = 0.0f; //_fadeOutTime = 0.0f; //_delayToPlayTime = 0.0f; //_delayToEndTime = 0.0f; _speedRatio = 1.0f; _isFirstFrame = true; _nextPlayStatus = _playStatus; if (isEditor) { _linkedAnimClip.Stop_Editor(false); //Stop은 하되 업데이트는 하지 않는다. (false) } else { _linkedAnimClip.Stop_Opt(false); } //_tAnimClipLength = _linkedAnimClip.TimeLength; _unitWeight = 0.0f; _isWeightCalculated = false; _totalRequestWeights = 0.0f; //_prevUnitWeight = 0.0f; //_debugWeight1 = 0.0f; //_debugWeight2 = 0.0f; //_debugWeight3 = 0.0f; //_isDelayIn = false; //_isDelayOut = false; //_tDelay = 0.0f; }
// Update is called once per frame void Update () { preventTrigger = true; if (Application.platform == RuntimePlatform.Android) { if (Input.GetKeyDown(KeyCode.Escape) && this.gameObject.activeSelf) { Debug.Log("Done!!"); CustomApplicationQuit(); } } if (isProcessingAudio == true) { if (pcmToUnityClip.IsDone == false) //show progress { if (arrayLength == 0) arrayLength = pcmToUnityClip.endvalue; else { float widthRate = 1-(((float)pcmToUnityClip.progress) / ((float)arrayLength)); loadingBar.GetComponent<RectTransform>().sizeDelta = new Vector2((int)(widthRate * 800.0f), 10); //UnityEngine.Debug.Log(pcmToUnityClip.progress + "/" + arrayLength); //UnityEngine.Debug.Log(pcmToUnityClip.progressWave); } } else //prepare data, show slider { loadingText.SetActive(false); loadingGroup.SetActive(false); isProcessingAudio = false; floatArray = pcmToUnityClip.getArray(); floatWaveData = pcmToUnityClip.getWaveData(); floatArrayMaximum = pcmToUnityClip.getMaximum(); //UnityEngine.Debug.Log("maximum is " + floatArrayMaximum); //UnityEngine.Debug.Log(floatArray.Length); UnityEngine.Debug.Log(floatWaveData.Length); //time stamp update float totaltime = (floatArray.Length) / (float)FREQUENCY; quarterTime.text = getTimeString2(totaltime / 4.0f); halfTime.text = getTimeString2(totaltime / 2.0f); softTime.text = getTimeString2(totaltime * 0.75f); endTime.text = getTimeString2(totaltime); AudioClip myClip = AudioClip.Create("record", floatArray.Length, 1, FREQUENCY, false, false); myClip.SetData(floatArray, 0); audioSource.clip = myClip; preventTrigger = true; playbackSlider.direction = Slider.Direction.LeftToRight; playbackSlider.minValue = 0; playbackSlider.maxValue = audioSource.clip.length; playbackSlider.value = 0; preventTrigger = false; groupReplayObjects.SetActive(true); } } else RefreshTopChart(); if (audioSource != null) { if (audioSource.isPlaying == true) { playbackSlider.value = audioSource.time; if (playbackSlider.value == playbackSlider.maxValue) { audioSource.Stop(); audioSource.time = 0; playbackSlider.value = 0; playStatus = PLAY_STATUS.STOP; //playbackButtonText.text = "Play"; <--- change texture playButton.sprite = sprPlaying; playStatus = PLAY_STATUS.STOP; } } } preventTrigger = false; }
public void jumpInPlayback() { if (preventTrigger == true) return; if (audioSource != null) { if (playbackSlider.value < audioSource.clip.length) { audioSource.time = playbackSlider.value; if (audioSource.isPlaying != true) { playButton.sprite = sprPausing; audioSource.Play(); playStatus = PLAY_STATUS.PLAY; } } } else UnityEngine.Debug.Log("cannot find an audiosource"); }
public TrackInfo(string track, string album, string artist, string art, ART_STATUS art_status, string genre, PLAY_STATUS playStatus, int offset, int time, int timeTotal) { dependsOn = new List <string> { "GET_now_playing" }; this.track = track; this.album = album; this.art = art; this.art_status = art_status; this.artist = artist; this.genre = genre; this.offset = offset; this.playStatus = playStatus; this.time = new TimeSpan(0, 0, time); this.timeTotal = new TimeSpan(0, 0, timeTotal); }
// Update is called once per frame void Update() { preventTrigger = true; if (Application.platform == RuntimePlatform.Android) { if (Input.GetKeyDown(KeyCode.Escape) && this.gameObject.activeSelf) { Debug.Log("Done!!"); CustomApplicationQuit(); } } if (isProcessingAudio == true) { if (pcmToUnityClip.IsDone == false) //show progress { if (arrayLength == 0) { arrayLength = pcmToUnityClip.endvalue; } else { float widthRate = 1 - (((float)pcmToUnityClip.progress) / ((float)arrayLength)); loadingBar.GetComponent <RectTransform>().sizeDelta = new Vector2((int)(widthRate * 800.0f), 10); //UnityEngine.Debug.Log(pcmToUnityClip.progress + "/" + arrayLength); //UnityEngine.Debug.Log(pcmToUnityClip.progressWave); } } else //prepare data, show slider { loadingText.SetActive(false); loadingGroup.SetActive(false); isProcessingAudio = false; floatArray = pcmToUnityClip.getArray(); floatWaveData = pcmToUnityClip.getWaveData(); floatArrayMaximum = pcmToUnityClip.getMaximum(); //UnityEngine.Debug.Log("maximum is " + floatArrayMaximum); //UnityEngine.Debug.Log(floatArray.Length); UnityEngine.Debug.Log(floatWaveData.Length); //time stamp update float totaltime = (floatArray.Length) / (float)FREQUENCY; quarterTime.text = getTimeString2(totaltime / 4.0f); halfTime.text = getTimeString2(totaltime / 2.0f); softTime.text = getTimeString2(totaltime * 0.75f); endTime.text = getTimeString2(totaltime); AudioClip myClip = AudioClip.Create("record", floatArray.Length, 1, FREQUENCY, false, false); myClip.SetData(floatArray, 0); audioSource.clip = myClip; preventTrigger = true; playbackSlider.direction = Slider.Direction.LeftToRight; playbackSlider.minValue = 0; playbackSlider.maxValue = audioSource.clip.length; playbackSlider.value = 0; preventTrigger = false; groupReplayObjects.SetActive(true); } } else { RefreshTopChart(); } if (audioSource != null) { if (audioSource.isPlaying == true) { playbackSlider.value = audioSource.time; if (playbackSlider.value == playbackSlider.maxValue) { audioSource.Stop(); audioSource.time = 0; playbackSlider.value = 0; playStatus = PLAY_STATUS.STOP; //playbackButtonText.text = "Play"; <--- change texture playButton.sprite = sprPlaying; playStatus = PLAY_STATUS.STOP; } } } preventTrigger = false; }