I’m trying to be able to initialize UMediaPlayer in C++, but it’s not allowing me.
I’ve included it on my cpp file (full directory Runtime/MediaAssets/Public/MediaPlayer.h) and added “MediaAssets” to PublicDependencies. When I want to initialize it, it tells me "incomplete type is not allowed.
I’ve been struggling to understand this for a while now and found a solution that worked for me, but I have not yet fully understood why.
The issue could be in Forward Declaration of your UMediaPlayer class in the YourCaller.h file.
Removing
class UMediaPlayer;
and adding\keeping only the
#include UMediaPlayer.h
in both YourCaller.h and *YourCaller.cpp" might do the trick for you.
I suspect the Circular Dependency concept is involved here, which you solve with Forward Declaration, but since you probably do not have this issue, Forward Declaration usecase (Forward declaration - Wikipedia) doesn’t really suite your needs.
Again, this is my wild guess on the problem and if someone could explain this better, that be very helpful.