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!