Getting sound effects to work in HTML5

Bringing your stacks to the web

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lrieber
Posts: 40
Joined: Sat Sep 24, 2011 6:30 pm
Location: Athens, Georgia USA
Contact:

Getting sound effects to work in HTML5

Post by lrieber » Sun Dec 27, 2015 6:59 pm

I finally have had a chance to play around a little with the option to export to HTML5 using LiveCode Community 8 (dp 12). I'm pleasantly surprised by how well it worked. But, I could not get any of my sound effects to work. I was careful to use the "copy files" option in standalone settings to copy the needed .wav files before exporting to HTML5. Does anyone have any advice on how to get sound to work?

Here's a link to the exported HTML5 project (called "Crack the Code"):
http://lrieber.coe.uga.edu/livecode/htm ... _Code.html

I also blogged about my experience:
http://learninglivecode.blogspot.com/20 ... could.html

Exciting direction for LiveCode!

Lloyd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Getting sound effects to work in HTML5

Post by [-hh] » Mon Jan 04, 2016 9:59 pm

AFAIK sound isn't (yet) implemented in the HTML5-standalone builder.
Lloyd wrote: ... but when I try running it from there, I get the error "Exception thrown, see JavaScript console." I presume that means my NowhereRoad server is not set up properly to run javascript, even though I thought it was. I obviously need to check into this.
I wonder, at all, how you manage to do some of the javascript code server-side, if not a server-side web application?
shiftLock happens

lrieber
Posts: 40
Joined: Sat Sep 24, 2011 6:30 pm
Location: Athens, Georgia USA
Contact:

Re: Getting sound effects to work in HTML5

Post by lrieber » Mon Jan 04, 2016 11:18 pm

Lloyd wrote: ... but when I try running it from there, I get the error "Exception thrown, see JavaScript console." I presume that means my NowhereRoad server is not set up properly to run javascript, even though I thought it was. I obviously need to check into this.
[-hh] wrote:I wonder, at all, how you manage to do some of the javascript code server-side, if not a server-side web application?
Thanks, hh, for your reply.

The more I think about it, the more confused I am as to why my HTML5 project only works when I try to run it from one web server and not another. Javascript is all client-side and is dependent on the browser. When I tested my project, I used the same computer and the same browser (Firefox) for all testing. Again, it works fine when run locally, but only works when downloaded from one of three different web servers.

Lloyd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Getting sound effects to work in HTML5

Post by [-hh] » Tue Jan 05, 2016 12:33 am

Lloyd,
I had this effect in a similar way:
Firefox, which is by far the best with caching large files, refused to run a standalone that worked with others (Safari/Chrome/Opera), no differences between platforms.

Presumably I found the reason for that:
The good caching requires on startup some price, say one second more loading time for the first time. But Firefox does the caching async.
If one now runs some startup jobs, using startup or preopenstack or openCard, or if one fires too early a short-beated routine (you have one that runs every 50 millisecs), then the main loop overflows and an exception is thrown.

One of my examples is clockAround, that worked in all browsers except Firefox.

Its first handler was
on preopenstack
    send "mouseUp" to btn "clockAround" in 1 tick
end preopenstack

Changing "1 tick" to "1 second" made it running perfectly in all (newest) browsers, even in Iceweasel on a RaspberryPi 2.

I learned: Give the standalone some time for starting up the "stack-world"(.zip). This is needed by the browsers for handling the large .js and .mem-files in memory and cache.

I bet, if you have no startup action and wait a second before starting the game (use 'send in time' in openCard), then your NowhereRoad server will also work (you did already speed up using DEFLATE in .htaccess?).

p.s. *After* 1-2 loads I have here (using the DEFLATE in .htaccess) loading times < 5 seconds from an extern server, for all modules that use the same LC version, with browser Firefox (which uses perfectly local cache).
Hermann
shiftLock happens

Post Reply

Return to “HTML5”