UMediaSoundComponent

Hey,

I’m trying to add a MediaSoundComponent to my C++ character, but whenever I do it throws out all of these errors on files I’ve never edited, and returns null on a file that should exist, correct me on that if I’m wrong.

Error C1083 Cannot open include file: ‘Components/MediaSoundComponent.h’: No such file or directory SurvivalCharacter.cpp 9
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int SurvivalCharacter.gen.cpp 22
Error C2146 syntax error: missing ‘;’ before identifier ‘UClass’
SurvivalCharacter.gen.cpp 22
Error C2065 ‘Z_Construct_UClass_UMediaSoundComponent_NoRegister’: undeclared identifier SurvivalCharacter.gen.cpp 319

Attached is my implementation of this component

H File
347548-
CPP File

I’ve tried regenerating the file a couple times but threw the same errors. Thanks!

Hello!

You most likely just need to add this in your project’s .Build.cs file:

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

I included Media as well as MediaAssets, but to get the MediaSoundComponent include to build you should only need to add MediaAssets.

And as a side note the include is:

#include "MediaSoundComponent.h"

or

#include "Engine/Source/Runtime/MediaAssets/Public/MediaSoundComponent.h"