I spawn multiple media players in my Sandbox game so I think I’ve figured this one out; it seems that when you set the source of the media player, the media texture seems to loose it’s link to the media player; so when it’s trying to read data it simple has no “media player” to read data / frames from.
The solution is to force an update of the underlying media texture resource, but it requires some C++.
In your xxx.build.cs make sure you have the “MediaAsset” dependancy:
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"CoreUObject",
"Engine",
...
"MediaAssets"
});
Then in a C++ actor, include the header at the top…
#include "MediaTexture.h"
Then inside your C++ object (the header file) - create a static function to do the magic:
UFUNCTION(BlueprintCallable, Category = "Modiverse")
static void UpdateMediaTexture(UMediaTexture* mediaTexture)
{
mediaTexture->UpdateResource();
}
Then BP process was similar as mentioned; create media texture in constructor script (not sure this is still required) and then in my “spawn” event I create media player, dynamic material (with a texture parameter set to the media texture), get my 3D plane and set it’s material to this dynamic material instance and finally I “Set Media Player” on the media texture (pointing it at the media player)… I then “Open URL” and after that call the above “UpdateMediaTexture” BP node to fix it… Seems to work fine in editor and published game!!
Hope this helps someone out!