public float GetAudioVolume(ushort trackIndex) { if (useAudioPlayer) { if (audioPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { return(audioPlayer.GetDirectAudioVolume(trackIndex)); } else if (audioPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { return(audioPlayer.GetTargetAudioSource(trackIndex).volume); } } else { if (videoPlayer.audioOutputMode == VideoAudioOutputMode.Direct) { return(videoPlayer.GetDirectAudioVolume(trackIndex)); } else if (videoPlayer.audioOutputMode == VideoAudioOutputMode.AudioSource) { return(videoPlayer.GetTargetAudioSource(trackIndex).volume); } } return(0f); }
private IEnumerator ScoreBoard() { float currVolume = player.GetDirectAudioVolume(0); while (!Mathf.Approximately(scoreBoard.alpha, 1.0f)) { player.SetDirectAudioVolume(0, (1 - scoreBoard.alpha) * currVolume); scoreBoard.alpha = Mathf.MoveTowards(scoreBoard.alpha, 1.0f, Time.deltaTime); yield return(null); } _audio.Play(); int bScore = PlayerPrefs.GetInt("BestScore", 0); string best = "Your Best Score " + bScore + " Kcal"; bestScore.text = best; yield return(new WaitForSeconds(1.0f)); string yours = ""; if (bScore < GameManager.Instance.Kcal) { yours = "The New Record!! " + GameManager.Instance.Kcal + " Kcal"; PlayerPrefs.SetInt("BestScore", GameManager.Instance.Kcal); PlayerPrefs.Save(); } else { yours = "Oops Try Again!!"; } yourScore.text = yours; yield return(new WaitForSeconds(1.0f)); btnGroup.SetActive(true); }
// private VideoPlayer tv; // Start is called before the first frame update void Start() { /* * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * VA AGGIUSTATO IL MANTENIMENTO DELLO STATO DI SIMULAIONE IN SIMULAZIONE??????????????????' */ //tv = GetComponent<VideoPlayer>(); //tv.Play(); GameObject tvSoggiorno = GameObject.FindGameObjectWithTag("20"); GameObject tvStanza = GameObject.FindGameObjectWithTag("21"); playerSoggiorno = tvSoggiorno.GetComponent <VideoPlayer>(); playerStanza = tvStanza.GetComponent <VideoPlayer>(); lastChannel = new VideoClip[2]; //soggiorno lastChannel[0] = playerSoggiorno.clip; //stanza lastChannel[1] = playerStanza.clip; // playerSoggiorno.clip = lastChannel[0]; // playerStanza.clip = lastChannel[1]; volumes = new float[2]; volumes[0] = playerSoggiorno.GetDirectAudioVolume(0); volumes[1] = playerStanza.GetDirectAudioVolume(0); }
// Update is called once per frame private void Update() { // Proceed to Restart if 'R' is pressed if (Input.GetKeyUp(KeyCode.R)) { Restart(); } // Increase volume by 0.1f if 'Up Arrow' is pressed if (Input.GetKeyUp(KeyCode.UpArrow)) { if (videoPlayer.GetDirectAudioVolume(0) + 0.1f < 1f) { videoPlayer.SetDirectAudioVolume(0, videoPlayer.GetDirectAudioVolume(0) + 0.1f); } else { videoPlayer.SetDirectAudioVolume(0, 1f); } } // Decrease volume by 0.1f if 'Down Arrow' is pressed if (Input.GetKeyUp(KeyCode.DownArrow)) { if (videoPlayer.GetDirectAudioVolume(0) - 0.1f > 0f) { videoPlayer.SetDirectAudioVolume(0, videoPlayer.GetDirectAudioVolume(0) - 0.1f); } else { videoPlayer.SetDirectAudioVolume(0, 0f); } } // When video is playing if (videoPlayer.isPlaying) { // Skip to second last second if (Input.GetKeyDown(KeyCode.Space)) { FinishPlaying(videoPlayer); } } }
public void changeVolume(int id, int action) { GameObject tv = GameObject.FindGameObjectWithTag(id.ToString()); VideoPlayer player = tv.GetComponent <VideoPlayer>(); //print("BOH" + player.audioTrackCount); player.SetDirectAudioVolume(0, action / 10f); volumes[0] = playerSoggiorno.GetDirectAudioVolume(0); volumes[1] = playerStanza.GetDirectAudioVolume(0); }
private void Update() { if (!isSkiping && (Input.GetKey(KeyCode.Joystick1Button7) || Input.GetKey(KeyCode.Joystick2Button7) || Input.GetKey(KeyCode.Escape))) { StartCoroutine(FadeOut()); } else if (isSkiping) { player.SetDirectAudioVolume(0, player.GetDirectAudioVolume(0) - 0.02f); } }
private void Update() { if (!isSkiping && (Input.GetKeyDown(KeyCode.Space))) { StartCoroutine(FadeOut()); } else if (isSkiping) { player.SetDirectAudioVolume(0, player.GetDirectAudioVolume(0) - 0.02f); } }
/// <summary> /// 動画が終わったら再生します。 /// </summary> /// <param name="time">待ち秒数</param> IEnumerator MovieFadeOut(float time) { yield return(new WaitForSeconds(time)); isAnimDone = false; canvasAnimator.SetBool("Show", false); // フェードが終わったら、タイトル開始 float fromVolume = videoPlayer.GetDirectAudioVolume(0); while (!isAnimDone) { yield return(null); videoPlayer.SetDirectAudioVolume(0, movieRawImage.color.a * fromVolume); narrationSource.volume = movieRawImage.color.a * narrationVolume; } StartTitle(); }
private void Update() { VidPlayer.SetDirectAudioVolume(0, Mathf.Lerp(VidPlayer.GetDirectAudioVolume(0), AudioTarget, Time.deltaTime * 2f)); }