Forum rules - please read before posting.

Way for Active Menus to Pause Video?

I know there's an option for active menus to pause game play but they don't seem to pause videos that may be playing. Is there any chance of adding this in a future update?

Comments

  • They should do already - so long as you are playing them back with the Engine: Play movie clip Action, and you have both Wait until finish? and Pause when game does? checked.

  • The only issue with that is the player has no option to pause when 'Wait until finish?' is selected as it disables the menus etc.

  • You can set the ActionList's When running field to Run In Background so that gameplay continues while it runs.

    Otherwise, you can just attach a simple script to the VideoPlayer component that pauses the video whenever AC itself is paused.

  • It's already set at 'Run in background' but alas, it doesn't pause it :/

    I'm useless with scripts in Unity, is there any way you could explain it to me please? If not it's no problem. Thanks, Chris :)

  • I'm not clear - you said the only issue was that the menus get disabled. Does the video pause when not running in the background?

    Sample script:

    using UnityEngine;
    using UnityEngine.Video;
    using System.Collections;
    using AC;
    
    public class VideoPauser : MonoBehaviour
    {
    
        public VideoPlayer videoPlayer;
        private bool isPaused;
    
        private void OnEnable ()
        {
            EventManager.OnEnterGameState += EnterGameState;
            EventManager.OnExitGameState += ExitGameState;
        }
    
        private void OnDisable ()
        {
            EventManager.OnEnterGameState -= EnterGameState;
            EventManager.OnExitGameState -= ExitGameState;
        }
    
        private void EnterGameState (GameState _gameState)
        {
            if (_gameState == GameState.Paused)
            {
                if (videoPlayer.isPlaying)
                {
                    videoPlayer.Pause ();
                    isPaused = true;
                }
            }
        }
    
        private void ExitGameState (GameState _gameState)
        {
            if (_gameState == GameState.Paused)
            {
                if (!videoPlayer.isPlaying && isPaused)
                {
                    isPaused = false;
                    videoPlayer.Play ();
                }
            }
        }
    
    }
    
  • The video did not pause even when 'running in the background'.

    However, the script you sent works 100% so far - the playing video now pauses when the in-game menu is opened. Brilliant!

    Should this do this as standard without the additional script when set to run in background? If so is there any chance if it can being added in a future update?

  • As I said, it should do already. And my own testing shows no such issue. You will have to provide full details (AC/Unity version numbers and steps to recreate) for me to be able to address it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.