Open pnostudiodeveloper opened 3 years ago
Remember you can use the null operator:
instead of
if (MediaPlayer.Control != null) { MediaPlayer.Control.Seek(time); }
MediaPlayer.Control?.Seek(time);
But yes, you're right - we do plan to clean this up so null never has to be checked for...
Thanks,
Describe the issue As I've been implementing AVPro Video, it's become clear that I can't count on the Control and Info properties to be available, unless the MediaPlayer has content successfully loaded into it.
The only solution seems to be trying to remember to write statements such as:
if (MediaPlayer.Control != null) { MediaPlayer.Control.Seek(time); }
This leads to my MediaPlayer code being a lot more verbose than necessary, a lot more typing, and a lot more anxiety. It introduces the risk that larger, important blocks of my code may end up occasionally halting halfway through due to a Null Reference error if the user hasn't loaded a video, and I forgot to write a null check for .Control / .Info.
There has to be some way that calls to Control or Info can fail more gracefully without throwing a Null Reference error, if a video hasn't been loaded yet - this is not an issue at all with Unity VideoPlayer.
Thank you for all the hard work you guys do on this framework!
Your Setup (please complete the following information):
To Reproduce
Please DO NOT LINK / ATTACH YOUR PROJECT FILES HERE
Instead email the link to us unitysupport@renderheads.com