It does play sound/music on PC browser without any problem but It doesn’t work on iOS mobile browser such as iOS Safari, iOS Chrome.
Maybe Defold engine is not capable to handle sound files on iOS mobile browser yet?
I have tested .ogg and .wav both.
With Android Chrome it’s working fine.
It would be really nice if Defold can play sound/music on iOS web browser (especially iOS Safari).
Is there any way to play sound/music on iOS Safari?
msg.post("main:/sound#menu","play_sound")
Defold version : 1.2.96
iOS version : 10.2
Android version : 4.4.4 (Chrome 55.0.2883.91)
edit
I know that iOS Safari won’t let you play sounds unless you call API first within user touch event.
So what I’m doing is that on gui_script handle the sound when user press button.
function on_input(self, action_id, action)
if action_id == hash("input_touch") or action_id == hash("input_mouse") then
if action.pressed then
local x = action.x
local y = action.y
local start_node = gui.get_node("play")
if gui.pick_node(start_node,x,y) then
msg.post("main:/sound#menu","play_sound") -- firing play_sound when user touches the button
msg.post("main:/loader#script","load",{"level_select"})
msg.post("main:/loader#script","unload",{"top_title"})
end
end
end
end