declare UMediaPlayer variable problem...

K so I have tried adding this to the header file with no luck,

#include “Runtime/MediaAssets/Public/MediaPlayer.h”

says file doesnt exist, and doing this,

UMediaPlayer MPlayer;

or

UMediaPlayer* MPlayer;

or

class UMediaPlayer MPlayer;

tells me variable type is undeclared, what am I doing wrong? missing something?

Wild guess: did you forget to add MediaAssets to your module dependencies list in Build.cs?

possibly simply because I didnt know I had to :smiley: learning on my own and never taken a real c++ class so im a bit lost.

I found the build.cs file and I am assuming this line is the one that adds the dependency:

PublicDependencyModuleNames.AddRange(new string] { “Core”, “CoreUObject”, “Engine”, “InputCore” });

I am a bit skeptical on changing this file so I may just do a master BP and create child BP’s for the final actors, or just make the BP customizable in the level.

My goal is to be able to play media files using the mediaplayer and I have managed to do that in blueprints and custom hud, would prefer to do it all in c++ but if the declaration is gonna need a large dependency, I think BP’s might be a more efficient solution.

Am I overthinking it?

Don’t worry about adding this as a dependency.

It’s really only telling the build system that your code will need access to this subsystem. The underlying MediaAssets code would be in the final build anyway as the Blueprint version would be using it, you’re not saving anything or causing any problems by making the change.

If your design would be cleaner and more constant with this in C++ then go for C++, having a ‘special case’ in Blueprint simply to avoid needing to tweak the build system feels off. You’ll likely find yourself needing to make similar build changes as you continue with your UE4 development, may as well start now.