您的位置:首页 > 移动开发 > Unity3D

Unity ios下播放视频文件

2016-12-16 13:39 453 查看
  以下代码是在IOS设备上播放视频文件

  [SerializeField] private RawImage _movieImage;

    private bool _isPlayingIntro = false;

    void Start () {

#if UNITY_STANDALONE_OSX || UNITY_EDITOR 

        _movieImage.gameObject.SetActive (true);

        var texture = (MovieTexture)_movieImage.mainTexture;

        texture.Play ();

        _isPlayingIntro = true;

#else

        Handheld.PlayFullScreenMovie ("Intro.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);

        _isPlayingIntro = true;

#endif

    }

    void Update () {

#if UNITY_STANDALONE_OSX || UNITY_EDITOR

        if (_isPlayingIntro && Input.GetMouseButtonDown (0)) {

            var texture = (MovieTexture)_movieImage.mainTexture;

            texture.Stop ();

            _movieImage.gameObject.SetActive (false);

            _isPlayingIntro = false;

        }else {    

            if (Input.GetKeyDown (KeyCode.Escape)) {

                Application.Quit ();

            }

        }

#else

        if (_isPlayingIntro && Input.GetMouseButtonDown (0)) {

            _isPlayingIntro = false;

        }

        if (Input.GetKeyDown(KeyCode.Escape)) {

            Application.Quit();

        }

#endif

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐