Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Video Player Time Left

Discussion in 'Timeline' started by freedom667, Feb 6, 2019.

  1. freedom667

    freedom667

    Joined:
    Sep 6, 2015
    Posts:
    425
    I use the video player component as URL. I want to make the time of a video as Time left, just like on facebook video player. when I open my video the time will show total time and it will count down but I have a scrub, play, pause, and restart button. anybody knows how can I do it?

    this shows total time

    Code (CSharp):
    1. void Update()
    2.     {
    3.        
    4.         if (videoPlayer != null)
    5.         {
    6.             progressSlider.value = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
    7.             double time = videoPlayer.frameCount / videoPlayer.frameRate;
    8.             System.TimeSpan VideoUrlLength = System.TimeSpan.FromSeconds(time);
    9.             string minutes = (VideoUrlLength.Minutes).ToString("00");
    10.             string seconds = (VideoUrlLength.Seconds).ToString("00");
    11.             currentVideoTime.text = minutes + ":" + seconds;
    12.         }
    13.     }