Godot Version
4.3
Question
I am Exporting my Game for a Web Build and then I tried hosting it on a local server as well as Itch for example. And I can’t hear any sounds at all
here is a part of the ready in my Audio Manager:
func _ready() -> void:
process_mode = PROCESS_MODE_ALWAYS
# Web-specific audio initialization
if OS.get_name() == "Web":
# Listen for input to unlock audio
var event_listener = func():
if JavaScriptBridge.eval("""
if (typeof window.audioContextStarted === 'undefined') {
window.audioContextStarted = true;
window.AudioContext = window.AudioContext || window.webkitAudioContext;
const audioContext = new AudioContext();
audioContext.resume();
console.log('Audio context initialized');
return true;
}
return false;
"""):
Logger.info("Web audio context initialized", LogType.INIT)
# Connect to input events
get_viewport().connect("gui_focus_changed", event_listener)