VDNA
October 20, 2018, 12:52pm
1
anyone knows how can i do video player time as countdown? it will start from length of video and countdown to zero. but it will be minutes and seconds. my script is this.
string minutes = Mathf.Floor((int)videoPlayer.time / 60).ToString("0");
string seconds = ((int)videoPlayer.time % 60).ToString("00");
currentVideoTime.text = minutes + ":" + seconds;
this part only video player time
nilsdr
October 20, 2018, 1:42pm
2
Invoke a function every second which gets the current time from the videoplayer
VDNA
October 21, 2018, 5:38pm
3
I couldn’t do it. can you help me?
timeSinceLastCheck += Time.deltaTime;
if (timeSinceLastCheck > 1.0){
//do update
TimeSinceLastCheck = 0;
}
VDNA
October 21, 2018, 6:25pm
5
I think it won’t work because I want to do this with video. there ise skipping, stop, play, pause everything. time.deltatime won’t work
Then
If (TimeLeft - totaltime > 1.0){
TimeLeft = video.timeLeft;
//do stuff
}
If it has a total time variable just use that minus what already played
VDNA
October 21, 2018, 8:16pm
8
but will it work on pause, skipping , stop etc? I tried this on my code but I couldn’t do it. this part is only looking forward
string minutes = Mathf.Floor((int)videoPlayer.time / 60).ToString("0");
string seconds = ((int)videoPlayer.time % 60).ToString("00");
currentVideoTime.text = minutes + ":" + seconds;
Well .time gives you the time that already played, that’s half the equation, but for the total time i don’t see a variable in the video player API, maybe the clip has that property
but what you can do is figure it out by the current frame, total frames and FPS and see how lond is left
VDNA
October 26, 2018, 1:29pm
10
SparrowsNest:
Well .time gives you the time that already played, that’s half the equation, but for the total time i don’t see a variable in the video player API, maybe the clip has that property
but what you can do is figure it out by the current frame, total frames and FPS and see how lond is left
I wrote this one. but does not work again. when countdown to zero at 1 minute, turning minus and. so like this: 1:-01,1:-02 etc
string minutes = Mathf.Floor(-(int)videoPlayer.time / 60 + (int)videoPlayer.clip.length / 60).ToString("0");
string seconds = (-(int)videoPlayer.time % 60 + (int)videoPlayer.clip.length % 60).ToString("00");
currentVideoTime.text = minutes + ":" + seconds;