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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -