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;
    }

}

最新文章

  1. docker对数据卷进行还原操作
  2. Codeforces Round #337 (Div. 2) A. Pasha and Stick 水题
  3. AngularJs项目
  4. cocoaPods的安装和使用之详细介绍
  5. java中的多线程——进度1
  6. .NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法
  7. A - 高精度(大数)N次方(第二季水)
  8. 网​址​U​R​L​中​特​殊​字​符​转​义​编​码
  9. OpenGL ES着色器语言之语句和结构体(官方文档第六章)内建变量(官方文档第七、八章)
  10. Redis持久化方式的选择
  11. SAM failed to write changes to the database 问题处理
  12. 【java 多线程】多线程并发同步问题及解决方法
  13. 小tips:node起一个简单服务,打开本地项目或文件浏览
  14. 【AtCoder】【模拟】【模型转化】Camel and Oases(AGC012)
  15. Go基础系列:import导包和初始化阶段
  16. (转)【学习笔记】通过netstat+rmsock查找AIX端口对应进程
  17. SPOJ11414 COT3 博弈论 + Trie树合并
  18. PHP中文件类型 文件属性 路径以及 文件相关的函数
  19. 琴声不等式--jensen
  20. asp.net c# 虾米音乐API

热门文章

  1. CodeForces1006D-Two Strings Swaps
  2. Dubbo 2.7新特性之异步化改造
  3. Vue中slot插槽的使用
  4. 关于页面打印window.print()的样式问题
  5. Linux三剑客之awk命令详解
  6. java面试题干货96-125
  7. Soc EmbeddedDesign Suite (EDS)13.1.0.162安装
  8. CCF-CSP题解 201509-3 模板生成系统
  9. 中国剩余定理(CRT)及其拓展(ExCRT)
  10. web前端分享JavaScript到底是什么?特点有哪些?