|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
fresherrice |
func _on_openmusic_file_selected(path):
var file = File.new()
file.open(path, File.READ)
$AudioStreamPlayer.stream = file.get_current_file()
###############################################
can somebody tell me what’s wrong?
|
|
|
 |
Reply From: |
kidscancode |
The stream
property of AudioStreamPlayer needs to be set to an AudioStream
Resource, not to a file. Godot automatically loads resources with load()
:
$AudioStreamPlayer.stream = load("res://path/to/audio/file")
so should I get the absolute path and
path = file.get_absolute_path()
$AudioStreamPlayer.stream = load(“path”)
fresherrice | 2021-07-09 16:03
You already have the file path. You don’t need to use the File object at all.
kidscancode | 2021-07-09 17:57