public IEnumerator PlayVideo() { GameObject.Find ("First Person Controller").GetComponent<Level10Health> ().guiEnabled = false; cam.depth = 2; GameObject.Find("Initialization").GetComponent<AudioSource>().audio.Stop(); GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = false; GameObject.Find("Initialization").GetComponent<AudioSource>().volume = 1; Screen.lockCursor = true; //Screen.showCursor = false; //GameObject.Find("Main Camera").GetComponent<MouseLook>().enabled = false; //GameObject.Find("First Person Controller").GetComponent<MouseLook>().enabled = false; movie = renderer.material.mainTexture as MovieTexture; audio.clip = movie.audioClip; audio.Play(); movie.Play(); yield return new WaitForSeconds(audio.clip.length); movie.Stop(); cam.depth = -2; audio.volume = 0; movie.Play(); audio.Play(); yield return new WaitForSeconds(0.2F); movie.Pause(); audio.Pause(); Screen.lockCursor = false; GameObject.Find("Initialization").GetComponent<AudioSource>().audio.clip = scary; audio.volume = 1; GameObject.Find("Initialization").GetComponent<AudioSource>().audio.Play (); GameObject.Find("Initialization").GetComponent<CursorTime>().showCursor = true; GameObject.Find ("First Person Controller").GetComponent<Level10Health> ().guiEnabled = true; //Application.LoadLevel(Application.loadedLevel); }
public void SetPaused(bool wasPaused) { Debug.Log("SetPaused: " + wasPaused); videoPaused = !videoPaused; #if (UNITY_ANDROID && !UNITY_EDITOR) if (mediaPlayer != null) { //videoPaused = wasPaused; try { mediaPlayer.Call((videoPaused) ? "pause" : "start"); } catch (Exception e) { Debug.Log("Failed to start/pause mediaPlayer with message " + e.Message); } if (!videoPaused && !audioEmitter.isPlaying) { audioEmitter.PlayDelayed(.6f); } if (videoPaused && audioEmitter.isPlaying) { audioEmitter.Pause(); } } #else if (movieTexture != null) { // videoPaused = wasPaused; if (videoPaused) { movieTexture.Pause(); if (audioEmitter != null) { audioEmitter.Pause(); } } else { movieTexture.Play(); if (audioEmitter != null) { audioEmitter.Play(); } } } #endif }
public void Pause() { if (_currentClip == null) { return; } if (_currentClip.isPlaying) { _isPlayed = false; ChangeVideoState(VideoState.paused); _currentClip.Pause(); _audioSource.Pause(); CancelInvoke("EndClip"); } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Jump")) { if (movie.isPlaying) { movie.Pause(); sound.Pause(); } else { movie.Play(); sound.Play(); } } }
/// <summary> /// Pause the video. /// </summary> public void Pause() { if (CurrentState != StateType.Started) { return; } #if USE_EASY_MOVIE_TEXTURE if (easyMovieTexture == null) { return; } easyMovieTexture.Pause(); #elif USE_UNITY_VIDEO_PLAYER if (videoPlayer == null) { return; } videoPlayer.Pause(); #elif USE_ANDROID_MEDIA_PLAYER if (mediaPlayer == null) { return; } try { mediaPlayer.Call("pause"); } catch (Exception e) { Debug.LogError(TAG + " Failed to pause mediaPlayer: " + e.Message); } #elif USE_VIVE_MEDIA_DECODER if (mediaDecoder == null) { return; } mediaDecoder.setPause(); #else if (movieTexture == null || audioSource == null) { return; } movieTexture.Pause(); audioSource.Pause(); #endif UpdateState(StateType.Paused); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) && movie.isPlaying) { movie.Pause(); } else if (Input.GetKeyDown(KeyCode.Space) && !movie.isPlaying) { movie.Play(); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.LoadLevel(1); } }
void Update() { if (Input.GetButtonDown("Jump")) { Renderer r = GetComponent <Renderer>(); MovieTexture movie = (MovieTexture)r.material.mainTexture; if (movie.isPlaying) { movie.Pause(); } else { movie.Play(); } } }
// Use this for initialization IEnumerator Start() { MovieTexture mt = this.renderer.material.mainTexture as MovieTexture; mt.Play(); if (this.pause) { yield return(new WaitForEndOfFrame()); yield return(new WaitForSeconds(this.whenToPause)); if (mt.isPlaying && this.pause) //check this.pause in case it got disabled during the x second wait. { mt.Pause(); this.pause = false; } } }
public void PausePlayVideo() { UnityEngine.Debug.Log("this is pausePlayVideo ->" + url); if (isPlaying) { UnityEngine.Debug.Log("video is playing !!"); if (movieTexture != null) { UnityEngine.Debug.Log("movie texture !=null"); timer.Stop(); movieTexture.Pause(); audioSource.GetComponent <AudioSource> ().Pause(); isPlaying = !isPlaying; pausePlayButton.GetComponent <Image> ().sprite = GetPausePlaySpriteFromState(); // c'est évident de mêttre un btn play ! StopCoroutine(coroutineToStopVideo); // ?????? // EndVideo(leftDuration) leftDuration -= GetPausedDurationFromStopWatch(); // timer.Reset(); } } else { UnityEngine.Debug.Log("video is not playing !!"); isPlaying = !isPlaying; pausePlayButton.GetComponent <Image> ().sprite = GetPausePlaySpriteFromState(); // mêttre un btn pause ! if (notPresent) { StartCoroutine(StartVideo(url)); } else { timer.Start(); movieTexture.Play(); audioSource.GetComponent <AudioSource> ().Play(); coroutineToStopVideo = EndVideo(leftDuration); // première instantiation de coroutine to stop video EndVideo StartCoroutine(coroutineToStopVideo); // EndVideo(0); } } }
void Update() { time += Time.deltaTime; if (time > movieLength) { SceneManager.LoadScene(nextScene); } if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)) { if (movie.isPlaying) { movie.Pause(); } else { movie.Play(); } } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Jump")) { var audioSource = GetComponent <AudioSource>(); GetComponent <Renderer>().material.mainTexture = movieTexture; if (movieTexture.isPlaying) { movieTexture.Pause(); audioSource.Pause(); } else { movieTexture.Play(); audioSource.Play(); } } }
/** * Pauses the game by freezing time and sounds. */ public void PauseGame() { // Work out which Sounds will have to be re-played after pausing Sound[] sounds = FindObjectsOfType(typeof(Sound)) as Sound[]; List <Sound> soundsToResume = new List <Sound>(); foreach (Sound sound in sounds) { if (sound.playWhilePaused && sound.IsPlaying()) { soundsToResume.Add(sound); } } #if !(UNITY_5 || UNITY_2017_1_OR_NEWER) // Disable Interactive Cloth components InteractiveCloth[] interactiveCloths = FindObjectsOfType(typeof(InteractiveCloth)) as InteractiveCloth[]; foreach (InteractiveCloth interactiveCloth in interactiveCloths) { interactiveCloth.enabled = false; } #endif Time.timeScale = 0f; //AudioListener.pause = true; // Now delay audiolistener pause for a frame becuase of a bug with Unity 2017 #if ALLOW_MOVIETEXTURES if (fullScreenMovie != null) { fullScreenMovie.Pause(); } #endif #if !(UNITY_5 || UNITY_2017_1_OR_NEWER) foreach (Sound sound in soundsToResume) { sound.ContinueFix(); } #endif StartCoroutine(PauseAudio()); }
private void Update() { rend.enabled = screenActive; if (Input.GetKey(KeyCode.P)) { if (!onPause) { movieTexture.Pause(); onPause = true; } else { movieTexture.Play(); onPause = false; } } if (Input.GetKey(KeyCode.F2)) { screenActive = false; } }
void Update() { segundo -= Time.deltaTime; if (segundo <= 0.0f) { Destroy(this.gameObject); segundo = 10.0f; } if (Input.GetKey(KeyCode.Space) && video.isPlaying) { video.Pause(); } if (Input.GetKey(KeyCode.Space) && !video.isPlaying) { video.Play(); } }
/** * Pauses the game by freezing time and sounds. */ public void PauseGame() { // Work out which Sounds will have to be re-played after pausing Sound[] sounds = FindObjectsOfType(typeof(Sound)) as Sound[]; List <Sound> soundsToResume = new List <Sound>(); foreach (Sound sound in sounds) { if (sound.playWhilePaused && sound.IsPlaying()) { soundsToResume.Add(sound); } } #if !UNITY_5 // Disable Interactive Cloth components InteractiveCloth[] interactiveCloths = FindObjectsOfType(typeof(InteractiveCloth)) as InteractiveCloth[]; foreach (InteractiveCloth interactiveCloth in interactiveCloths) { interactiveCloth.enabled = false; } #endif Time.timeScale = 0f; AudioListener.pause = true; #if !(UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_WEBGL || UNITY_TVOS) if (fullScreenMovie != null) { fullScreenMovie.Pause(); } #endif #if !UNITY_5 foreach (Sound sound in soundsToResume) { sound.ContinueFix(); } #endif }
void Update() { if (Input.GetButtonDown("Jump")) { Renderer r = GetComponent <Renderer>(); MovieTexture movie = (MovieTexture)r.material.mainTexture; //aud = movie.audioClip; movie.loop = true; if (movie.isPlaying) { movie.Pause(); } else { movie.Play(); //movie.audioClip.Play(); //aud.Play(); //aud = movie.audioClip; //aud.Play(); } } }
IEnumerator OnCloseWelcome() { yield return(new WaitForSeconds(1)); isPlaying = true; movTexture.Play(); AudioSource audio = GetComponent <AudioSource>(); audio.clip = movTexture.audioClip; audio.Play(); image_Movie.texture = movTexture; image_Movie.gameObject.SetActive(true); image_BackGround.gameObject.SetActive(true); yield return(new WaitForSeconds(3.6f)); movTexture.Pause(); Application.LoadLevel("Main"); movTexture.Stop(); audio.Stop(); //image_Movie.gameObject.SetActive(false); //image_BackGround.gameObject.SetActive(false); }
/// <summary> /// Pauses video playback when the app loses or gains focus /// </summary> void OnApplicationPause(bool wasPaused) { Debug.Log("OnApplicationPause: " + wasPaused); #if (UNITY_ANDROID && !UNITY_EDITOR) if (mediaPlayer != null) { videoPaused = wasPaused; try { mediaPlayer.Call((videoPaused) ? "pause" : "start"); } catch (Exception e) { Debug.Log("Failed to start/pause mediaPlayer with message " + e.Message); } } #else if (movieTexture != null) { videoPaused = wasPaused; if (videoPaused) { movieTexture.Pause(); if (audioEmitter != null) { audioEmitter.Pause(); } } else { movieTexture.Play(); if (audioEmitter != null) { audioEmitter.Play(); } } } #endif }
public void togglePlay() { playing = !playing; if (playing) { if (loaded) { vidQuad.SetActive(true); movieTexture.Play(); source.Play(); masterControl.instance.toggleInstrumentVolume(false); } else if (!loading) { StartCoroutine(movieRoutine()); } } else if (loaded) { movieTexture.Pause(); masterControl.instance.toggleInstrumentVolume(true); } }
public void Play(bool flag) { isPlay = flag; //Debug.LogWarning("Play : " + isPlay); if (isPlay) { image.sprite = pauseSprite; if (!movTexture.isPlaying) { movTexture.Play(); audioSource.Play(); } } else { image.sprite = playSprite; //暂停播放 movTexture.Pause(); audioSource.Pause(); image.sprite = playSprite; } }
// Update is called once per frame void Update() { if (movieTex.isPlaying) { videoTime += Time.deltaTime; } renderer.material.mainTexture = movieTex; if (myScript.videoPauseFlag) { movieTex.Pause(); } else { movieTex.Play(); } if (videoTime >= myScript.videoTotalTime) { movieTex.Stop(); this.gameObject.SetActive(false); } }
void OnGUI() { if (GUILayout.Button("播放/继续")) { //播放/继续播放视频 if (!movTexture.isPlaying) { movTexture.Play(); } } if (GUILayout.Button("暂停播放")) { //暂停播放 movTexture.Pause(); } if (GUILayout.Button("停止播放")) { //停止播放 movTexture.Stop(); } }
void PauseResume() { TD.PauseTrigger = false; if (!music.isPlaying) { pause = false; music.Play(); if (useMovBG) { mov.Play(); } PauseButtonText.text = "Pause"; } else { pause = true; music.Pause(); if (useMovBG) { mov.Pause(); } PauseButtonText.text = "Resume"; } }
/// <summary> /// Pause custom MovieTexture. /// </summary> /// <param name='mt'> /// MovieTexture. /// </param> public static void PauseMovie(MovieTexture mt) { mt.Pause(); }
override public float Run() { #if UNITY_WEBGL return(0f); #elif UNITY_IOS || UNITY_ANDROID || UNITY_WP8 if (!isRunning && filePath != "") { isRunning = true; if (canSkip) { Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.CancelOnInput); } else { Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.Full); } return(defaultPauseTime); } else { isRunning = false; return(0f); } #elif UNITY_5 || UNITY_PRO_LICENSE if (movieClip == null) { ACDebug.LogWarning("Cannot play movie - no movie clip set!"); return(0f); } if (movieClipType == MovieClipType.OnMaterial && material == null) { ACDebug.LogWarning("Cannot play movie - no material has been assigned. A movie clip can only be played as a material's texture, so a material must be assigned."); return(0f); } if (includeAudio && sound == null) { ACDebug.LogWarning("Cannot play movie audio - no Sound object has been assigned."); } if (!isRunning) { isRunning = true; guiTexture = null; KickStarter.playerInput.skipMovieKey = ""; if (movieClipType == MovieClipType.FullScreen) { CreateFullScreenMovie(); } else if (movieClipType == MovieClipType.OnMaterial) { if (movieMaterialMethod == MovieMaterialMethod.PlayMovie) { material.mainTexture = movieClip; } else if (movieMaterialMethod == MovieMaterialMethod.PauseMovie) { if (material.mainTexture == movieClip) { movieClip.Pause(); isRunning = false; return(0f); } } else if (movieMaterialMethod == MovieMaterialMethod.StopMovie) { if (material.mainTexture == movieClip) { movieClip.Stop(); isRunning = false; return(0f); } } } movieClip.Play(); if (includeAudio && sound != null) { if (movieClipType == MovieClipType.OnMaterial && movieMaterialMethod != MovieMaterialMethod.PlayMovie) { if (movieMaterialMethod == MovieMaterialMethod.PauseMovie) { sound.GetComponent <AudioSource>().Pause(); } else if (movieMaterialMethod == MovieMaterialMethod.StopMovie) { sound.Stop(); } } else { sound.GetComponent <AudioSource>().clip = movieClip.audioClip; sound.Play(false); } } if (movieClipType == MovieClipType.FullScreen || willWait) { if (canSkip && skipKey != "") { KickStarter.playerInput.skipMovieKey = skipKey; } return(defaultPauseTime); } return(0f); } else { if (movieClip.isPlaying) { if (!canSkip || KickStarter.playerInput.skipMovieKey != "") { return(defaultPauseTime); } } if (includeAudio) { sound.Stop(); } movieClip.Stop(); KickStarter.playerInput.skipMovieKey = ""; if (movieClipType == MovieClipType.FullScreen) { EndFullScreenMovie(); } isRunning = false; return(0f); } #else ACDebug.LogWarning("On non-mobile platforms, this Action is only available in Unity 5 or Unity Pro."); return(0f); #endif }
public void Pause() { audioPlayer.Pause(); movieTexture.Pause(); }
protected void Pause() { _movie.Pause(); _audio.Pause(); }
public override void OnEnter() { movieTexture.Pause(); Finish(); }
override public float Run() { if (movieClipType == MovieClipType.VideoPlayer) { #if UNITY_5_6_OR_NEWER && !UNITY_SWITCH if (videoPlayer != null) { if (!isRunning) { isRunning = true; if (movieMaterialMethod == MovieMaterialMethod.PlayMovie) { #if UNITY_WEBGL if (!string.IsNullOrEmpty(movieURL)) { videoPlayer.url = movieURL; } #else if (newClip != null) { videoPlayer.clip = newClip; } #endif if (prepareOnly) { videoPlayer.Prepare(); if (willWait) { return(defaultPauseTime); } } else { KickStarter.playerInput.skipMovieKey = ""; videoPlayer.Play(); if (videoPlayer.isLooping) { ACDebug.LogWarning("Cannot wait for " + videoPlayer.name + " to finish because it is looping!", videoPlayer); return(0f); } if (canSkip && skipKey != "") { KickStarter.playerInput.skipMovieKey = skipKey; } if (willWait) { return(defaultPauseTime); } } } else if (movieMaterialMethod == MovieMaterialMethod.PauseMovie) { videoPlayer.Pause(); } else if (movieMaterialMethod == MovieMaterialMethod.StopMovie) { videoPlayer.Stop(); } return(0f); } else { if (prepareOnly) { if (!videoPlayer.isPrepared) { return(defaultPauseTime); } } else { if (pauseWithGame) { if (KickStarter.stateHandler.gameState == GameState.Paused) { if (videoPlayer.isPlaying && !isPaused) { videoPlayer.Pause(); isPaused = true; } return(defaultPauseTime); } else { if (!videoPlayer.isPlaying && isPaused) { isPaused = false; videoPlayer.Play(); } } } if (canSkip && skipKey != "" && KickStarter.playerInput.skipMovieKey == "") { videoPlayer.Stop(); isRunning = false; return(0f); } if (!videoPlayer.isPrepared || videoPlayer.isPlaying) { return(defaultPauseTime); } } videoPlayer.Stop(); isRunning = false; return(0f); } } else { ACDebug.LogWarning("Cannot play video - no Video Player found!"); } #else ACDebug.LogWarning("Use of the VideoPlayer for movie playback is only available in Unity 5.6 or later."); #endif return(0f); } #if (UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_TVOS) if (!isRunning && filePath != "") { isRunning = true; if (canSkip) { Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.CancelOnInput); } else { Handheld.PlayFullScreenMovie(filePath, Color.black, FullScreenMovieControlMode.Hidden); } return(defaultPauseTime); } else { isRunning = false; return(0f); } #elif UNITY_STANDALONE && (UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE) && !UNITY_2017_2_OR_NEWER if (movieClip == null) { ACDebug.LogWarning("Cannot play movie - no movie clip set!"); return(0f); } if (movieClipType == MovieClipType.OnMaterial && material == null) { ACDebug.LogWarning("Cannot play movie - no material has been assigned. A movie clip can only be played as a material's texture, so a material must be assigned."); return(0f); } if (includeAudio && sound == null) { ACDebug.LogWarning("Cannot play movie audio - no Sound object has been assigned."); } if (!isRunning) { isRunning = true; guiTexture = null; KickStarter.playerInput.skipMovieKey = ""; if (movieClipType == MovieClipType.FullScreen) { CreateFullScreenMovie(); } else if (movieClipType == MovieClipType.OnMaterial) { if (movieMaterialMethod == MovieMaterialMethod.PlayMovie) { material.mainTexture = movieClip; } else if (movieMaterialMethod == MovieMaterialMethod.PauseMovie) { if (material.mainTexture == movieClip) { movieClip.Pause(); isRunning = false; return(0f); } } else if (movieMaterialMethod == MovieMaterialMethod.StopMovie) { if (material.mainTexture == movieClip) { movieClip.Stop(); isRunning = false; return(0f); } } } movieClip.Play(); if (includeAudio && sound != null) { if (movieClipType == MovieClipType.OnMaterial && movieMaterialMethod != MovieMaterialMethod.PlayMovie) { if (movieMaterialMethod == MovieMaterialMethod.PauseMovie) { sound.GetComponent <AudioSource>().Pause(); } else if (movieMaterialMethod == MovieMaterialMethod.StopMovie) { sound.Stop(); } } else { sound.GetComponent <AudioSource>().clip = movieClip.audioClip; sound.Play(false); } } if (movieClipType == MovieClipType.FullScreen || willWait) { if (canSkip && skipKey != "") { KickStarter.playerInput.skipMovieKey = skipKey; } return(defaultPauseTime); } return(0f); } else { if (movieClip.isPlaying) { if (!canSkip || KickStarter.playerInput.skipMovieKey != "") { return(defaultPauseTime); } } OnComplete(); isRunning = false; return(0f); } #else ACDebug.LogWarning("On non-mobile platforms, this Action is only available in Unity 5 or Unity Pro."); return(0f); #endif }
public void pauseMovie() { movie.Pause(); //sound.Pause (); }
public void DoPause() { movieTexture.Pause(); audioSource.Pause(); }
public void PauseMovie() { MovTexture.Pause(); }