Quick Question: UMediaplayer is undefined

Hello,

I want to use UMediaplayer, but unfortunately I can not use the Class in Visual Studio. I get the message, that UMediaplayer is undefined.

I added extra this:

#include "..\Source\Runtime\MediaAssets\Public\MediaPlayer.h"    

And I call this command in an Actor Class

UMediaPlayer* m_mediaPlayer = ConstructObject<UMediaPlayer>(UMediaPlayer::StaticClass()); 

Can someone give me code, which initialize a mediaplayer? Could not find anything in the internet

Hey -

You’ll want to make sure you include the MediaAssets module in the Build.cs file. Doing so should allow the code you posted to compile successfully.

Cheers

Hello ,

I change/added to my .Build.cs these lines:

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "MediaAssets", });

        PublicIncludePaths.AddRange(new string[] {"MediaAssets/Public",});

And to my Class, where I want to use the module

#include "MediaPlayer.h"

It does not work. What I’m doing wrong?

Greetings

Hey -

Adding “MediaAssets” to the PublicDependencyModuleNames.AddRange() as you have and including the entire header path (Runtime/MediaAssets/Public/MediaPlayer.h) successfully compiled when I used the same line of code you posted originally. You shouldn’t need to have the PublicIncludePaths.AddRange()

Cheers