Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
safeSound — Gideros Forum

safeSound

Some platforms may have problems loading sound, for example different web browsers. You may not know about it because in some countries one type of browser may be more popular than another - so you won't have the errors but loads of others might. The same may apply to different variations on Android, etc...

So I've made this little function that will return even if the sound doesn't load properly:
function safeSound(f)
	ok,result=pcall(Sound.new,f)
	print(ok,result)
	if ok then
		return result
	else
		print("Error loading sound: "..f)
		print(result)
		return false
	end
end
If it returns false then don't use the sound, else it's ok.

Likes: pie, Apollo14

Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
+1 -1 (+2 / -0 )Share on Facebook

Comments

  • If you have access to an event system - like flurry, facebook instant events, or firebase then it might be a good idea to send a message back with the filename, etc... so you can try alternative formats.

    Likes: Apollo14

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.