2 Comments

Adding music


I hit a snag although I got the audio working. Below is an example of what the (Webkit, Safari/Chrome) browser is capable of.

But there’s a problem. I use pageloads in some scene changes, for example when you go from the garage to the newspaper and vice versa.

The audioengine (HTML5 AudioContext) is started on window load. Therefore, if you have multiple pageloads the engine reloads/inits again.

Thus, if I play a tune in the garage and go the newspaper the music is stopped, the garage page is loaded and the tune is started again at the beginning. That’s not what I want, the music should continue playing when you change scenes.

There are several ways to solve this. The one I prefer is to rebuild the current web application into an asynchronous variant (complete Ajax if you will) so only 1 pageload takes place. The content is replaced/updated by Javascript. I’m not looking forward to it but this is, in my opinion, the cleanest way to deliver a game with correct working audio/music.

2 comments on “Adding music

  1. Yeah make it tottaly in ajax is better, but if you load the music in one frame and game in another frame… music will aways run in a clean way and you can put another static things there!

    • My plan is to not use iframes. The idea is to create one html page on which the audio player is added. Game screens will be rendered onto this page with Ajax while the music conitnues to play.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: