Selecting a FileMediaSource as variable in a C++ written node. Used by MediaPlayer.

I am using a Media player to play small MP4 files.
In blueprints this works. I have a Media texture which I can place on any mesh.
I can also choose a different clip with the node “OpenSource”.

Now in a C++ class I have made my own node which requires some parameters.
For now it has a simple boolean called “LastChoice”, which can be set in blueprints.
But I also want this node to have a selectable parameter for a clip to play.

From the tooltip, I gather I need a “MediaSource” type of variable.
But that just gives an error in the code.
The documentation tells me to “include MediaSource”, but that also gives an error.

How do I declare a parameter in my UFUNCTION so that I can select a videoclip?

And if I did not have this forum, where in the documentation would I look to find the answer?

Add “MediaAssets” as public dependency in your Build.cs

Then include should work

Then use UMediaSource* as function parameter type.

Thanks, the Build.cs thing helped a lot!

No more errors with the include or parameter type.

However now, when compiling, it says “missing default argument for parameter 2”.
I am guessing I need to give it a value like I set the bool “bLastChoice” to true.
I can easily come up with something if its a bool, int, float, String.
But setting a Default value for a UMediaSource, I dont know.

Looking at the documentation I am guessing it expects a filepath to a “FileMediaSource”?

How would I make a default value for a UMediaSource?

Use nullptr for default value for object pointers