Unity WebGL打包加载视频 || PC端 || 手机端 ,检测视频加载完成.

请添加图片描述

using UnityEngine;
using UnityEngine.Video;

public class Welcome1 : MonoBehaviour
{
//string video_Path = “http://yuzhicai.boyaokj.cn/upload/fenjingyuyan.mp4”;//网络加载视频播放
string video_Path = “”;
public VideoPlayer videoplayer;//从场景中拖入挂载VideoPlayer组件的RawImage

public GameObject Moves;
public GameObject Modle;

//检测视频是否播放完毕
void Awake()
{
    videoplayer.loopPointReached += test; //设置委托
}
//视频加载完成执行的条件
void test(VideoPlayer video)//videoplayer = video2
{
    Debug.Log("播放完毕");
    Moves.SetActive(false);
    Modle.SetActive(true);
}

//开始加载视频播放
void Start()
{
    //video_Path = Path.Combine(Application.streamingAssetsPath, "example.mp4");
    video_Path = Application.streamingAssetsPath + "/example.mp4";//本地视频加载,视频放在StreamingAssets文件夹下
    videoplayer.url = video_Path;
   
}
 //点击按钮播放视频
public void Play_Moves()
{
    videoplayer.Play();
}
//点击按钮暂停视频播放
public void Play_Stop()
{
    videoplayer.Stop();
}

}

猜你喜欢

转载自blog.csdn.net/qq_42986916/article/details/125553552
今日推荐