Unreal Engine 4使用C++(低级别)从链接中加载视频
我正在尝试使用链接在媒体播放器中加载视频 这是我的C ++编码,如果您有任何想法,请给我建议
UMediaTexture* MyTexture = NewObject<UMediaTexture>(this);
UStreamMediaSource* streamMediaSource = NewObject<UStreamMediaSource>(this);
UMediaPlayer* mediaPlayer = NewObject<UMediaPlayer>(this);
mediaPlayer->StreamUrl("https://docs.unrealengine.com/4.26/Attachments/WorkingWithMedia/MediaFramework/HowTo/StreamMediaSource/Infiltrator%20Demo.mp4");
mediaPlayer->OpenSource(streamMediaSource);
MyTexture->SetMediaPlayer(mediaPlayer);
MyTexture->UpdateResource();
mediaPlayer->Play();
Mesh->SetMaterial(0, UnrealMaterial);
DynamicMaterial = UMaterialInstanceDynamic::Create(UnrealMaterial, this);
if (DynamicMaterial != nullptr)
{
Mesh->SetMaterial(0, DynamicMaterial);
DynamicMaterial->SetScalarParameterValue(TEXT("EmissiveStrength"), 50);
DynamicMaterial->SetTextureParameterValue(TEXT("Param"), MyTexture);
}
,并尝试其他方式,例如:
UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
TextureExpression->Texture = MyTexture;
TextureExpression->SamplerType = SAMPLERTYPE_External;
UnrealMaterial->Expressions.Add(TextureExpression);
UnrealMaterial->BaseColor.Expression = TextureExpression;
创建动态材料将C ++文件转换为蓝图,但视频不加载,其他方式我们使用Create BluePrint和C ++文件中的设置纹理示例,例如
DynamicMaterial->SetScalarParameterValue(TEXT("EmissiveStrength"), 50);
DynamicMaterial->SetTextureParameterValue(TEXT("Param"), MyTexture);
请帮我
i am try to load video in media player using link but we can`t play video in low level(C++) but high level(BluePrint) is working fine
here is my C++ coding please if you have any idea give me suggestion
UMediaTexture* MyTexture = NewObject<UMediaTexture>(this);
UStreamMediaSource* streamMediaSource = NewObject<UStreamMediaSource>(this);
UMediaPlayer* mediaPlayer = NewObject<UMediaPlayer>(this);
mediaPlayer->StreamUrl("https://docs.unrealengine.com/4.26/Attachments/WorkingWithMedia/MediaFramework/HowTo/StreamMediaSource/Infiltrator%20Demo.mp4");
mediaPlayer->OpenSource(streamMediaSource);
MyTexture->SetMediaPlayer(mediaPlayer);
MyTexture->UpdateResource();
mediaPlayer->Play();
Mesh->SetMaterial(0, UnrealMaterial);
DynamicMaterial = UMaterialInstanceDynamic::Create(UnrealMaterial, this);
if (DynamicMaterial != nullptr)
{
Mesh->SetMaterial(0, DynamicMaterial);
DynamicMaterial->SetScalarParameterValue(TEXT("EmissiveStrength"), 50);
DynamicMaterial->SetTextureParameterValue(TEXT("Param"), MyTexture);
}
and try also other way like:
UMaterialExpressionTextureSample* TextureExpression = NewObject<UMaterialExpressionTextureSample>(UnrealMaterial);
TextureExpression->Texture = MyTexture;
TextureExpression->SamplerType = SAMPLERTYPE_External;
UnrealMaterial->Expressions.Add(TextureExpression);
UnrealMaterial->BaseColor.Expression = TextureExpression;
and create Dynamic Material convert c++ file to Blueprint but video not load and other way we uses create blueprint and set texture sample uses in c++ file like
DynamicMaterial->SetScalarParameterValue(TEXT("EmissiveStrength"), 50);
DynamicMaterial->SetTextureParameterValue(TEXT("Param"), MyTexture);
please help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码中可能存在一些错误。
试试这个。
Here is some error in your code maybe.
Try this.