Help! C++ UMediaTexture is not showing UMediaPlayer Frames when playing a UStreamMediaSource

As the title already describes, I’m trying to play a video from URL and use the frames in a material.
I’m btw using UE4.19, launcher version

Here the code I use to load and play the video:


  
VideoTexture = NewObject<UMediaTexture>(this);
VideoTexture->AddToRoot();
VideoSource = NewObject<UStreamMediaSource>(this);
VideoSource->AddToRoot();
VideoPlayer = NewObject<UMediaPlayer>(this);
VideoPlayer->AddToRoot();

// Link the Video Texture to the Media Player
VideoTexture->SetDefaultMediaPlayer(VideoPlayer);
VideoTexture->SetMediaPlayer(VideoPlayer);


VideoSource->StreamUrl = VideoURL;
VideoPlayer->SetLooping(true);
VideoPlayer->OpenSource(VideoSource);
VideoPlayer->PlayOnOpen = true;
VideoPlayer->Play();

SetDynamicTexture(VideoTexture); // Adds the texture to the dynamic material


For VideoURL I use a demo .mp4 video. When doing exactly the same using blueprints, the video is playing.
Using C++ the video also seems to get played, since I can observe how its first buffering (print string) and then having the “IsPlaying” status.
But the Texture just stays black all the time.
For sure it compiles without any error or warning.

It seems like the UMediaPlayer frames get not written to the UMediaTexture.
Did I miss somthing?

I appreciate any help, thanks in advance!

Best Regards
Robin :slight_smile:

Hi Robin,

Did you get an answer to this question or figured out how to get a media player working through code in UE4?

Thanks!

Hey!

I’ve actually found a solution to this issue, yes. It was about calling a function on the UMediaTexture, I think, which then makes it “refresh” and actually play the video.
Unfortunately I don’t know anymore how this function was called exactly, but I’m sure you’ll find it :slight_smile:

Best Regards!