redrocketcms.classes.Soundtrack
The soundtrack is actually a pretty complex system. Inherently, the problem with streaming music on the fly into flash is that when music "Streams", flash automatically "drops frame" to sync with the music, regardless if this music is in the library, or loaded externally.
So, what we’ve done is used an external swf that does all the playing, loading, and management of the music. This is the "Soundtrack Source". However, you never see this swf, it’s loaded and hidden from view to be controlled from an external movie.
All the communication is done through flash’s LocalConnection Object. The internals are pretty complex, but in the end, we’re left with a nice clean interface to run all our commands with, with almost no overhead, and streaming without choking.
Note: the system uses a SiteKey as the "handshake" to run all the soundtrack transmissions. This is done to make sure that just this website is being affected. however, if you have the same website open in multiple tabs, or multiple browsers, Soundtrack actions will be transmitted to them all, thereby affecting them all. Sometimes cool, sometimes not cool.
Note: currently, as of this writing, the Soundtrack is an AS1 class, but it still uses namespaces for the day when it does (and trust me it will) become AS2. So, for future compatibility, and for current functionality, do not use the import command, but interact with the class directly, since all the functions are static anyhow. Example:
var Soundtrack = _global.redrocketcms.classes.Soundtrack;
Soundtrack.transmit("setVolume", 50);
or even this would work:
_global.redrocketcms.classes.Soundtrack.transmit("setVolume", 50);
Static.
Adds an object to the subscriber base for callbacks. In addition to automatic transmissions, with many of the actions you can send, data gets transmitted back to the client (controlling swf). Below are the callbacks you may chose to enable:
onLoadRatio(ratio:Number);
The loading of each song is transmitted. you can display this information based on the ratio paramater sent. It is an integer between 0 to 1 where 1 is completely loaded.
onPositionRatio(ratio:Number);
the track position of the currently playing song is transmitted. You can display this information based on the ratio paramter sent. It is an integer bewteen 0 and 1 where 1 is the end of the track.
onVolume(volume:Number);
The volume of the Soundtrack is transmitted each time the volume is set either programatically, or by user intervention. The volume paramter is an integer from 0 to 100 where 100 is the loudest.
onTrack(index:Number, song:Object);
Each time the track changes, either automatically, or by user intervention, track information is transmitted. The index property indicates where in the playlist order it is now playing (zero based). The song object contains 3 string properties: title, filename, id3. Note: the id3 property may or may not have any useful information, and is presented as is.
onPlaylist(playlist:Array);
The playlist is transmitted when the getPlaylist action is issued, and when the soundtrack gets initialized. The playlist array is an array of objects, with each object containing song information. Each song object contains 3 string properties: title, filename, id3. Note: the id3 property may or may not have any useful information, and is presented as is.
onPlaybackStatus(status:String);
The current playback status. "playing" if the engine is playing "paused" if paused, "stopped" if stopped.
Example usage:
Static.
Called from the client swf (the controlling swf), you can use this command to control all the aspects of the Soundtrack engine. Below is the list of actions available, along with any additional paramters:
Static.
Removes an object from the subscriber base for callbacks.