using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Thousandto.Plugins.Common { /// /// UI视频Utils /// public class UIVideoPlayUtils { #region//static private static VideoRootScript script = null; #endregion #region//属性 public static VideoRootScript Script { get { if (script == null) { var go = GameObject.Find("[VideoRoot]"); if (go) { script = go.GetComponent(); } else { //创建videoRoot var asset = Resources.Load("Default/System/VideoRoot"); var videoRoot = GameObject.Instantiate(asset) as GameObject; videoRoot.name = "[VideoRoot]"; if (videoRoot != null) { GameObject.DontDestroyOnLoad(videoRoot); script = videoRoot.GetComponent(); if (script == null) { script = videoRoot.AddComponent(); } } } } return script; } } #endregion #region//static方法 //准备视频 public static void PreVideo(string name, VideoRootScript.OnPreparedCall preparedCallBack = null, VideoRootScript.OnFinishCall finishCall = null, bool isShowMask = false, bool isLoop = false, VideoPlayExt extType = VideoPlayExt.Mp4) { if (Script != null) Script.PrepareVideo(name, preparedCallBack, finishCall, isShowMask, isLoop, extType); } //播放视频 public static void PlayVideo(string name, VideoRootScript.OnPreparedCall preparedCallBack = null, VideoRootScript.OnFinishCall finishCall = null, bool isShowMask = false, bool isLoop = false, VideoPlayExt extType = VideoPlayExt.Mp4) { if(Script != null) Script.Play(name, preparedCallBack, finishCall, isShowMask, isLoop, extType); } //停止视频播放 public static void StopVideo() { if(Script != null) Script.StopVideo(); } //判断是否正在播放视频 public static bool IsPlaying() { if(Script != null) return Script.IsPlaying(); return false; } //设置视频depth public static void SetDepth(float d) { if(Script != null) Script.SetCamraDepth(d); } #endregion } }