In widget blueprint i create two buttons ( Play - Stop )
and i link play button with 2d sound
but i realized i can’t find stop sound to link to stop button , i think this not available in UMG , if there another way to stop sound , please tell me how to do this.
I think your best bet is to remove all that stuff and do a on event click cast to another blueprint. An actor blueprint. You can use your game blueprint and then in the game blueprint set your audio component to the sound selected by the array.
That way you can get the audio component and select stop.
You will have to do the same for the stop button.
Doesnt look like you can add audio components to UMG and by the looks of it you will need one.
Well actually forget about the game blueprint. You are already casting to your character i see.
On your character add a Audio component.
Create a custom event in your character blueprint.
Call it Start Music or something like that. Create another one called Stop Music.
Then In your UMG after you cast to you character run the custom event.
And at your custom events you add your logic and then play sound and stop sound.
I can give screenshots but it will have to wait till later today unfortunately. Basically you need to control your music on your character… drag n drop the audio component into the event graph on your character and when you drag from it you will the option to stop.
You just need to set the audio to play by doing that stuff that was in the answerhub post.
Still didn’t work Audio Component , i edit Structure and add variable to Audio Component and i follow your instructions, but it seems doesn’t work
here screen shot
I know this is an old post but this is the way i did it.
Right click, Create Sound 2D (Select the sound you want) then Promote it to a variable, I named mine BGM, then drag from the Return Value of your BGM and type Play.
[ATTACH=JSON]{“data-align”:“none”,“data-size”:“full”,“data-tempid”:“temp_129793_1518920746081_528”}[/ATTACH]
Then Get the BGM reference that you have, drag from the Return Value and type Stop.