赞
踩
注:此方法播放视频仅支持ogv格式。
由于此播放视频的方法只支持ogv格式视频,而我们常见的视频格式大多是mp4、flv、avi等格式。所以我们需要对视频进行格式转换。
而格式转换所使用的工具为:Theora Converter .NET
将需要转换的视频拖入箭头指向区域,完成转换输出配置后,点击start即开始转换格式。
将转换好的视频文件放入资源库里,创建视频管理类
- using UnityEngine;
- using System.Collections;
- using System;
- using Assets.Scripts.UI;
-
- public class MovieManage: SingletonUI<MovieManage>
- {
- public GameObject FigerGestures;
- private string rootPath = "File_Movie/";//存放音乐的地址
- private MovieTexture movieTexture;
- private UITexture uiTexture;
- private AudioSource as1;
- private int State = 1;//0为视频暂停状态;1为视频播放状态;
-
- private Action<string> action;
- private bool checkFlag = false;
- private string currentPlayMovieName;
- private int width = 0;
- private int height = 0;
-
- private bool SPFlag = true;
- private bool autouShut;
- private Transform uicamera = null;
-
- public void setAction(Action<string> action)
- {
- this.action = action;
- }
- // Use this for initialization
- void Start () {
- uicamera = GameObject.Find("UI Root
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。