How to Know video player is finished playing video?

@abhayaagrawal I was also looking for an answer for this and found this thread but could not really make heads or tails of it. My video only plays once so there is no looping involved. But I made up my own way of checking if the video is finished playing!

//Play the video!
VP.GetComponent<VideoPlayer>().Play();

//Invoke repeating of checkOver method
InvokeRepeating("checkOver", .1f,.1f);
//checkOver function will use current frame and total frames of video player video
//to determine if the video is over.

private void checkOver()
{
       long playerCurrentFrame = VP.GetComponent<VideoPlayer>().frame;
       long playerFrameCount = Convert.ToInt64(VP.GetComponent<VideoPlayer>().frameCount);
     
       if(playerCurrentFrame < playerFrameCount)
       {
           print ("VIDEO IS PLAYING");
       }
       else
       {
           print ("VIDEO IS OVER");
          //Do w.e you want to do for when the video is done playing.
       
          //Cancel Invoke since video is no longer playing
           CancelInvoke("checkOver");
       }
}

Hope this helps someone else! I spent way too much time on figuring this out and figured I would share!

9 Likes