(Bug?). I can't open a file with the media player trough a UI.

I am trying to load a .WAV file into the game at runtime using the media player trough a UI. However I am not hearing anything. And before you ask:

  • Yes, the file works correctly. Because the exact same code works when placed in a normal actor.
  • Yes, all the booleans at the end return true.
  • And yes, the event fires.

Here is my current code.

This code is in my UI.

And this code is in my actor.

The music gets played when I press “1”. But not when its called from the UI. I have also tried doing it via a replicated variable update function. But that gives the same result.

I just don’t get why this doesn’t work. First of, why can you not put the code in image 2 in the UI? Because when its played, it can be treated like a sound 2D. And secondly, why is it different if I call the same event from my actor vs my UI? This should be the same.

I think its a bug. But if someone has a solution, please let me know. Because this has been really frustrating. Thank you!

Connect url from playmusic to create path from directory.

That url input does nothing. It is only there for later. The function always uses the same file right now.

So, the play music function from actor is IDENTICAL as one in the UI?

Yes. That is the weird part.

add some print string along the ui to see if they all execute (1,2,3…).Also check if the music is playing (is_playing) and such.

I already checked that. They all return true. And it is playing. The issue is that the MediaSoundComponent doesn’t work. Even if its added to my actor.

Aedan manul is the actor?

Yes.

first , you need to refrenc it by get all actors of a class(index 0)(if that is the only one!) and refrence the media sound component in play music function of UI bplueprint.

Wait. But the music function is in my actor. And I referenced the actor in my UI when calling the function.

Ok, then try get all actors of a class rather than get actor of a class.

Alright. I will test that. Although I don’t think it will work. Because this actor only exists once. But I will let you know.

Hello again. Sorry for the wait. I had to move my project to Unreal 5.7.4. I have tested it. And it doesn’t work. And my actor does indeed only exist once in the world.

The actor has to be in the levels. Weather drag and drop in levels, or spawn, or put the code in player character or in a blank actor you put in a level or whatever, but the actor has to be in the level. And you need to use get all actors of a class (get 0) to reference it or use some other technique.

Yes. They are in the level. And I used get all actors of class. The code is identical. The only difference is that I trigger the event from the UI instead of the actor.

Sometimes if you check this on event begin (in UI widget) the actor may not be loaded in the level, so it doesn’t fetch the reference to that actor. Check for errors and warning in the log.

I have no errors in the log. And the event does fire. All checks return true. But I just don’t hear anything. So I think that the MediaSoundComponent doesn’t work for some reason even though everything is identical.

I finally solved it. You need to add the MediaSoundComponent at runtime for some reason. But now it works. I can now play my .WAV file from a UI. Although the old code should have worked as well. So I still think its a bug.