Unity3D VidoePlayer 加载StreamingAssets下视频
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
public class VideoPlayerControl : MonoBehaviour
{
public VideoPlayer videoPlayer;
[SerializeField]
string format = ".mp4";
[SerializeField]
string videoName = "";
[SerializeField]
string foldPath;
[SerializeField]
RawImage rawImage;
private void Awake()
{
if (!rawImage)
{
}
}
private void Start()
{
videoPlayer.url = GetFilePath(foldPath, videoName, format);
}
private void OnGUI()
{
if (GUILayout.Button("Play"))
{
videoPlayer.Play();
rawImage.texture = videoPlayer.texture;
}
}
string GetFilePath(string foldPath, string fileName, string fileFormat = ".mp4")
{
string filePath;
#if UNITY_IPHONE
if (!string.IsNullOrEmpty(foldPath))
{
filePath="file://"+Application.dataPath + "/Raw/"+foldPath+"/"+fileName+fileFormat;
}
else
{
filePath="file://"+Application.dataPath + "/Raw/"+fileName+fileFormat;
}
#endif
if (!string.IsNullOrEmpty(foldPath))
{
filePath = Application.dataPath + "/StreamingAssets/" + foldPath + "/" + videoName + fileFormat;
}
else
{
filePath = Application.dataPath + "/StreamingAssets/" + videoName + fileFormat;
}
return filePath;
}
}
最新文章
- docker对数据卷进行还原操作
- Codeforces Round #337 (Div. 2) A. Pasha and Stick 水题
- AngularJs项目
- cocoaPods的安装和使用之详细介绍
- java中的多线程——进度1
- .NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法
- A - 高精度(大数)N次方(第二季水)
- 网​址​U​R​L​中​特​殊​字​符​转​义​编​码
- OpenGL ES着色器语言之语句和结构体(官方文档第六章)内建变量(官方文档第七、八章)
- Redis持久化方式的选择
- SAM failed to write changes to the database 问题处理
- 【java 多线程】多线程并发同步问题及解决方法
- 小tips:node起一个简单服务,打开本地项目或文件浏览
- 【AtCoder】【模拟】【模型转化】Camel and Oases(AGC012)
- Go基础系列:import导包和初始化阶段
- (转)【学习笔记】通过netstat+rmsock查找AIX端口对应进程
- SPOJ11414 COT3 博弈论 + Trie树合并
- PHP中文件类型 文件属性 路径以及 文件相关的函数
- 琴声不等式--jensen
- asp.net c# 虾米音乐API