This loads and plays a file for me.
var ap:AudioStreamPlayer
func _ready():
var fd = FileDialog.new()
add_child(fd)
fd.position = Vector2(100, 100)
fd.size = Vector2(800, 500)
fd.file_mode = FileDialog.FILE_MODE_OPEN_ANY
fd.visible = true
fd.access = FileDialog.ACCESS_FILESYSTEM
fd.connect('file_selected', show_me)
ap = AudioStreamPlayer.new()
add_child(ap)
func show_me(file):
if file and file.right(4) == '.ogg':
print(file)
var ogg = load(file)
print(ogg)
ap.stream = ogg
ap.play()
Edit: I can get this to work for mp3s that are not in the project, but not for ogg.
func show_me(file):
if file and file.right(4) == '.mp3':
print(file)
var dat = FileAccess.get_file_as_bytes(file)
var mp3 = AudioStreamMP3.new()
mp3.data = dat
ap.stream = mp3
ap.play()