- Home /
Question by
parmardarshanv · Jan 16, 2020 at 05:38 AM ·
videotimeline
I want to know if the video has been completed in unity.
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.
Comment
Answer by hameed-ullah-jan · Jan 16, 2020 at 06:46 AM
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");
}
}
Your answer
Follow this Question
Related Questions
Unity Timeline video showing black screen 1 Answer
MovieTexture cutscene - performance issues (stuttering) in Unity5 0 Answers
Why did they take down this video? 0 Answers
Play a video on a cube 1 Answer