home *** CD-ROM | disk | FTP | other *** search
- class SoundChannel
- {
- var channelid;
- var sound;
- var index;
- var volume;
- var mode;
- var playlist;
- var sync = false;
- var threshold = 500;
- function SoundChannel(sync)
- {
- if(typeof _root.soundchannels != "object")
- {
- _root.soundchannels = new Array();
- _root.createEmptyMovieClip("soundchannelclips",4095);
- }
- this.channelid = _root.soundchannels.length;
- _root.soundchannels.push(this);
- var _loc3_ = _root.soundchannelclips.createEmptyMovieClip("channel" + this.channelid,this.channelid);
- this.sound = new Sound(_loc3_);
- this.index = 0;
- this.volume = 100;
- this.mode = 0;
- if(sync != undefined)
- {
- this.sync = sync;
- }
- if(this.sync)
- {
- this.sound.onSoundComplete = this.NextAll;
- }
- }
- function SetPlaylist(arr)
- {
- this.playlist = arr;
- var _loc3_ = 0;
- var _loc2_ = 0;
- while(_loc2_ < this.playlist.length)
- {
- _loc3_ += this.playlist[_loc2_].length;
- _loc2_ = _loc2_ + 1;
- }
- }
- function GetCurrentTrack()
- {
- return this.playlist[this.index];
- }
- function FarQueue(s)
- {
- this.playlist.push(s);
- }
- function NearQueue(s)
- {
- this.playlist.splice(this.index + 1,0,s);
- }
- function SetVolume(v)
- {
- if(v != undefined)
- {
- this.volume = v;
- }
- v = Math.floor(this.volume * this.GetCurrentTrack().volume / 100);
- this.sound.setVolume(v);
- }
- function AddVolume(v)
- {
- var _loc2_ = this.volume + v;
- if(_loc2_ < 0)
- {
- _loc2_ = 0;
- }
- if(_loc2_ > 100)
- {
- _loc2_ = 100;
- }
- this.SetVolume(_loc2_);
- }
- function Pause()
- {
- this.sound.stop();
- }
- function Stop()
- {
- this.Pause();
- this.index = 0;
- this.mode = 0;
- }
- function Play()
- {
- this.mode = 1;
- var _loc2_ = this.GetCurrentTrack();
- if(!_loc2_)
- {
- return undefined;
- }
- this.sound.attachSound(_loc2_.file);
- this.SetVolume();
- this.sound.start();
- }
- function Next()
- {
- if(this.mode == 0)
- {
- return undefined;
- }
- var _loc2_ = this.GetCurrentTrack();
- if(!_loc2_.Next())
- {
- return undefined;
- }
- this.index = this.index + 1;
- if(this.index >= this.playlist.length)
- {
- this.index = 0;
- }
- this.Play();
- }
- function NextAll()
- {
- var _loc2_ = 0;
- while(_loc2_ < _root.soundchannels.length)
- {
- _root.soundchannels[_loc2_].Next();
- var _loc3_ = _root.soundchannels[_loc2_];
- _loc2_ = _loc2_ + 1;
- }
- }
- }
-