c# - Accessing dimensions (width/height) from a VideoPlayer source URL -


i working on unity project requires me download video file (mp4 format) , play using videoplayer component. because file downloaded @ runtime, have "stream" via url downloaded location, opposed loading videoclip.

to accurately size target rendertexture , gameobject video playing to, need dimensions of video file itself. because not videoclip cannot use:

videoclip clip = videoplayer.clip; float videowidth = clip.width; float videoheight = clip.height; 

because using source url opposed videoclip, return null.

can video dimensions directly file somehow?

you can retrieve these information texture videoplayer constructs.

get videoplayer

videoplayer videoplayer = getcomponent<videoplayer>(); 

get texture videoplayer

texture vidtex = videoplayer.texture; 

get videoplayer dimension width/height

float videowidth = vidtex.width; float videoheight = vidtex.height; 

make sure texture after videoplayer.isprepared true. see other answer full code on how play video make display on rawimage component.


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

html - How to custom Bootstrap grid height? -