I am making a vr game in unity in which I have added a video player. I want to add an event when the video is completed. How can I retrieve the time elapsed in video player so I can know if the video is completed.
Hi you can use these methods
Method1:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class Scene_Intro : MonoBehaviour {
public VideoPlayer vid;
void Start(){vid.loopPointReached += CheckOver;}
void CheckOver(UnityEngine.Video.VideoPlayer vp)
{
print ("Video Is Over");
}
}
Method 2:
public double time;
public double currentTime;
// Use this for initialization
void Start () {
time = gameObject.GetComponent<VideoPlayer> ().clip.length;
}
// Update is called once per frame
void Update () {
currentTime = gameObject.GetComponent<VideoPlayer> ().time;
if (currentTime >= time) {
Debug.Log ("//do Stuff");
}
}