Graphics Reference
In-Depth Information
7.4.7 Sound
The first version of Edge Animate does not yet support sound. This is because
support for playing audio is not yet standard across platforms. The Edge Com-
mons sound feature is a wrapper for the SoundJS function and CreateJS library
but also offers a simple method for playing sound in Edge Animate. SoundJS
supports all modern browsers, and also runs on mobile devices with some lim-
itations. Accordingly, this feature is still in the experimental phase. Actual use of
the feature should be reviewed for each project.
The Edge Commons encapsulates SoundJS so that using audio in your
compositions is simple. Before you can play an audio file, you have to convert it
into an HTML5-compatible format (such as MP3 or OGG). The following exam-
ple assumes that the two sound files were saved in both formats and placed
in the project's media subfolder. Now at the start of the composition (e.g., in
the creationComplete event), we can set up the sound files by defining a
manifest for the individual sounds and their corresponding files, and pass this to
the EC.Sound.setup() function:
// Load sound manifest (e.g. in creationComplete)
var assetsPath = "media/";
EC.Sound.setup(
[
{src: assetsPath + "bassdrum.mp3|"
+ assetsPath + "bassdrum.ogg", id: "bassdrum"},
{src: assetsPath + "snaredrum.mp3|"
+ assetsPath + "snaredrum.ogg", id: 'snaredrum'}
],
function(){ EC.info("Sound setup inished", "DEMO");
}
);
We define the two sounds with the IDs bassdrum and snaredrum . Both
are assigned to the paths of the corresponding MP3 and OGG files, separated
by a vertical bar or pipe character. Now we can play the audio in our project
anywhere via the EC.Sound.play (SOUND_ID) function:
// Play sound (e.g. on click)
EC.Sound.play("bassdrum");
7.4.8 Data Injection
Frequently, external data is needed within a composition. Edge Commons offers
the possibility to inject data into the containing HTML document. This can be
 
Search WWH ::




Custom Search