1.在一个plane上播放

1
2
3
4
5
6
7
8
9
10
11
12
using UnityEngine;
using System.Collections;
public class MobileMovieTexture : MonoBehaviour
{
public MovieTexture movTexture;
 
void Start()
{
GetComponent<Renderer>().material.mainTexture = movTexture;
movTexture.Play();
}
}

2.GUI.DrawTexture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using UnityEngine;
using System.Collections;
public class moiveTextureGUi : MonoBehaviour
{
public MovieTexture mt;
 
void Start()
{
mt.loop = true;
}
void OnGUI()
{
GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height),mt,ScaleMode.StretchToFill);
 
if (GUILayout.Button("play"))
{
if (!mt.isPlaying)
{
mt.Play();
}
}
}
}

3. Handheld.PlayFullScreenMovie

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using UnityEngine;
using System.Collections;
 
/// <summary>
/// 事先装个QuickTime
/// 一般在游戏开始前,会播放一个CG动画,点击屏幕救你可以关闭了
/// 视频文件放在StreamingAssets文件夹下
/// </summary>
public class TestHeadMoiveOnMobile : MonoBehaviour
{
void Start()
{
Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
}
void OnGUI()
{
//视频播放时触摸屏幕视频关闭
if (GUI.Button(new Rect(20, 10, 300, 50), "PLAY ContronlMode.CancleOnTouch"))
{
Handheld.PlayFullScreenMovie("test.mp4",Color.black,FullScreenMovieControlMode.CancelOnInput);
}
 
//视频播放时弹出控件,控制视频暂停,播放,全屏等
if (GUI.Button(new Rect(20, 90, 200, 50), "PLAY ControlMode.Full"))
{
Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Full);
}
 
//视频播放时无法停止,当其播放完一次 后自动关闭
if (GUI.Button(new Rect(20, 170, 200, 50), "PLAY ControlMode.Hidden"))
{
Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Hidden);
}
 
//视频播放时弹出控件,可控制播放进度
if (GUI.Button(new Rect(20, 250, 200, 50), "PLAY ControlMode.Minimal"))
{
Handheld.PlayFullScreenMovie("test.mp4", Color.black, FullScreenMovieControlMode.Minimal);
}
}
}

第三种方式,只能在真机上测试,才有效果哦。
一般选用:视频播放时触摸屏幕视频关闭
Handheld.PlayFullScreenMovie(“test.mp4″,Color.black,FullScreenMovieControlMode.CancelOnInput);

最新文章

  1. Enabling Cross-Origin Requests in ASP.NET Web API 2
  2. 使用Font Awesome替换你的网站图标
  3. 【转】PHP简单拦截器的实现
  4. HTML5 API——无刷新更新地址 history.pushState/replaceState 方法
  5. 写了个Linux包过滤防火墙
  6. ajax加php实现三级联动
  7. Spring-Data-JPA学习
  8. ExtJS4中initComponent和constructor的区别
  9. 在keil中使用printf()函数的要点
  10. HDU-1664-Different Digits(BFS)
  11. XMPP系列(七)---获取群组列表
  12. 表单提交前,判断webuploader是否上传
  13. Ubuntu 16.04下GDB调试
  14. 【XSY1081】随机存储器 网络流
  15. C# test
  16. JavaScript——事件机制
  17. 后端python基础
  18. 【c++】函数默认参数
  19. 关于C#的强制转换和尝试转换的方法
  20. 彻底解决Webpack打包慢的问题

热门文章

  1. [React] Return a list of elements from a functional component in React
  2. mac 上多版本python 共存
  3. JAVA的IO流:打印流
  4. poj 2409 Let it Bead Polya计数
  5. 门窗ERP——让门窗幕墙加工更简单
  6. 请求大神,C#如何截取字符串中指定字符之间的部分 按指定字符串分割 一分为二 c# 去除字符串中的某个已知字符
  7. WORD文档书签管理
  8. Log4Net 最最最基本的应用。作为个人记录
  9. Python3 range()函数
  10. linux 实时显示文件的内容