I am working on a Unity project that requires me to download a video file (mp4 format) and play it using the VideoPlayer component. Because the file is downloaded at runtime, I
You can retrieve these information from the Texture that VideoPlayer constructs.
Get VideoPlayer
VideoPlayer videoPlayer = GetComponent<VideoPlayer>();
Get the Texture VideoPlayer
Texture vidTex = videoPlayer.texture;
Get VideoPlayer dimension width/height
float videoWidth = vidTex.width;
float videoHeight = vidTex.height;
Make sure to only get the texture after videoPlayer.isPrepared
is true
. See my other answer for full code on how to play video make it display on RawImage
component.