Incorrect video Length printouts between 2018 and 2019 unity
Hi all. I wanted to write this question here 1st before asking stackoverflow as i'm hoping there is a quick solution to this:
I'm writing a script using the videoplayer functions and noticed a weird bug when trying to get the video Length from a url and not a clip. When using the videoplayer clip you can get the correct length of the video your playing as a double.
However:
When using a url you are not allowed to get the Length until the video is prepared.
When the video is prepared, you can access it from the scripting API description by using the video.Length function for urls.
I do not want a solution involving ANY 3rd party solution currently.
So i've tried dividing the frameCount by the frame rate, tried dividing directly by a number(target frames per second), getting the length from the direct call listed above, and have recieved an issue that i can't solve:
When using the clip.length you reccieve exact end time
when using the url, the video length in time is rounded down in 2018.
when using the url, the video length in time is rounded up in 2019.
when using the url, dividing by the frameCount with a direct number will round it down.
Run on an update, the end of the video current time reaches the end time of the video(rounded up), but the ending length of the url video then updates and rounds up. (2019)
Question at hand:
- how do i get the exact frame to time length of a url in Unity without it rounding my numbers up/down? I need the length to be exact to the time length.
I've tried:
Convert.ToInt64 long to float
Convert.ToDouble double to float
both cases round as well.
Since the time lengths on urls are different between engines i'm kind of stuck here. Any information as to why the numbers are rounded differently would be greatly appreciated.
Note:
This is to suggest trying a video playback in 2 different versions of Unity and check the ending lengths of a video.
getting the videoplayer ".Length" function means updating to Unity 2018.3 or up. Otherwise you have the videoplayer.clip.length as the only accessible way to get a video length as it wasn't added to the api. So your option is to divide by the total frame count. Which is rounded differently. Updating to 2019 this option is present (videoplayer ".Length") but rounds the video length up?