Hi All,
I am observing that OpenUrl fails always. I have tried keeping the file inside Blueprints->Movies of my project folder, on desktop etc, but it always fails. Please help.
The mesh is not obtained as null and on printing the url is obtained as “C:\Users\100365\Documents\Unreal Projects\UI_explore\Content\StarterContent\Blueprints\Movies\t1.wmv”
The code I am using is given below:
UMediaPlayer * m_mediaPlayer = ConstructObject<UMediaPlayer>(UMediaPlayer::StaticClass());
if (m_mediaPlayer != NULL)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:m_mediaPlayer successfully created!"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:m_mediaPlayer creation failed!"));
}
UMediaTexture * m_mediaTexture = ConstructObject<UMediaTexture>(UMediaTexture::StaticClass());
if (m_mediaTexture != NULL)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:m_mediaTexture successfully created!"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:m_mediaTexture creation failed!"));
}
m_mediaPlayer->SetLooping(false);
m_mediaTexture->SetMediaPlayer(m_mediaPlayer);
//add the media texture to the mesh
UStaticMeshComponent * mesh = AAMyActorExtendingClass::GetMyWall();
if (mesh != NULL)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:mesh successfully created!"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:mesh creation failed!"));
}
UMaterialInstanceDynamic * material = mesh->CreateDynamicMaterialInstance(0);
material->SetTextureParameterValue("Video", m_mediaTexture);
mesh->SetMaterial(0, material);
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Play_MediaTexture: url name: %s"), *url));
if (m_mediaPlayer->OpenUrl(url))
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:OpenUrl success!"));
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Play_MediaTexture:OpenUrl failed!"));
}
m_mediaPlayer->Rewind();
m_mediaPlayer->Play();