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

unity3d 安卓播放视频不使用视频纹理

2014-11-15 18:04 253 查看
导出apk,是不能用电影纹理的,所以我们只能用这个办法

这个

Handheld.PlayFullScreenMovie();

或者这个函数

iPhoneUtils.PlayMovie();

void OnGUI()
    {

        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 - 10,  100,20), "(h)CancelOnTouch"))
        {
            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 10, 100, 20), "(h)Full"))
        {
            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Full);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 30, 100, 20), "(h)Hidden"))
        {
            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Hidden);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 50, 100, 20), "(h)Minimal"))
        {
            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Minimal);
        }

      
    }


FullScreenMovieControlMode有四种模式,


1.视频播放时触摸屏幕视频关闭
2.视频播放时弹出IOS高级控件,控制视频暂停播放 全屏等等。
3.视频播放时无法停止,当其播放完一次后自动关闭
4.视频播放时弹出IOS高级控件,可控制播放进度。
另外,如果要跳转场景的话,直接
void Start()
    {
        this.audio.Play();
        Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Hidden);
        Application.LoadLevelAsync("in");
    }


就会播放完成,自动跳转

四种模式
iPhoneUtils.PlayMovie();
也是一样
void OnGUI()
    {

        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 - 10, 100, 20), "(i)CancelOnTouch"))
        {
            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.CancelOnTouch, iPhoneMovieScalingMode.AspectFit);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 10, 100, 20), "(i)Full"))
        {

            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Full, iPhoneMovieScalingMode.AspectFit);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 30, 100, 20), "(i)Hidden"))
        {
            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Hidden, iPhoneMovieScalingMode.AspectFit);
        }

        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 50, 100, 20), "(i)Minimal"))
        {
            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Minimal, iPhoneMovieScalingMode.AspectFit);
        }
    }


iPhoneMovieControlMode的方法已经过时,可以换成FullScreenMovieControlMode

iPhoneMovieScalingMode就是调scale的模式,设为null就行。
照常理这样就可以播放了,

但是又遇到了另一个问题
不播放视频,一片漆黑,但是显示着最终时间
这个就是手机分辨率的问题,切记分辨率(GAME面板中)一定要和手机设置的一样,否则就不会播放


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