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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -