Yes, you can load .wav (and other media) files dynamically at runtime using only blueprints. This will work both in the editor and in builds.
-
In the content browser, create a “Media Player”. Open it and ensure that “Play on Open” is checked.
-
Create an actor blueprint and open it.
-
In the “Components” pane of the blueprint (upper left corner), use “Add Component”, “Media Sound”.
-
Select the newly created media sound, and in the “Details” panel on the right, under “Media”, select your Media Player asset that you created in step 1.
-
In the “My Blueprint” pane, under Variables/Components, drag the media sound into the event graph and chose “get”.
-
From this node, drag and search for “Get Media Player”.
-
Create a variable of type Media Player. Drag it into the event graph and select “set”.
-
From the “BeginPlay” event, set your Media Player variable from the “Get Media Player” node
-
When you’re ready, get the input filepath to the audio file by whatever means you choose.
-
Use the Utilities/String/Replace node to replace all backslashes with forward slashes in the filepath.
-
Prepend the filepath with “file://” using the String/Append node. Your filepath is now a url.
-
Optionally, use the MediaPlayer “Can Play Url” node to validate the audio url before opening.
-
Drag the Media Player variable into the graph with “get”, and drag off of that and search for “open url”. This will begin playing the audio file.
-
On windows, if you run into issues with playback (such as stuttering or audio ending too early), try fiddling with these, hit “set as default”, and restart UE4:
-
Project Settings → Plugins → WMF Media → Media → Allow Non-Standard Codecs
-
Project Settings → Plugins → WMF Media → Media → Low Latency
-
Project Settings → Plugins → WMF Media → Debug → Native Audio Out