首页 > 代码库 > unity3d 安卓播放视频替代视频纹理
unity3d 安卓播放视频替代视频纹理
导出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高级控件,可控制播放进度。
四种模式
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面板中)一定要和手机设置的一样,否则就不会播放
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。