| Package | vegas.media |
| Class | public class CoreSound |
| Inheritance | CoreSound flash.media.Sound |
| Implements | Action, ISound, Resumable, Startable, Stoppable |
Example :
// See in the library of this fla file the BipSound Sound symbol and this linkage class id.
import system.events.ActionEvent ;
import vegas.date.Time ;
import vegas.events.SoundEvent ;
import vegas.media.CoreSound ;
import flash.media.SoundChannel ;
var debug:Function = function( e:ActionEvent ):void
{
trace(e) ;
}
var soundComplete:Function = function( e:Event ):void
{
var time:Time = new Time( (e.target as CoreSound).length ) ;
trace( e.type + " duration " + time.getMilliseconds(2) + " ms" ) ;
}
var soundUpdate:Function = function( e:SoundEvent ):void
{
trace( e.type + " volume:" + e.soundTransform.volume ) ;
}
var sound:CoreSound = new BipSound() ;
sound.addEventListener( Event.SOUND_COMPLETE , soundComplete ) ;
sound.addEventListener( SoundEvent.SOUND_UPDATE , soundUpdate ) ;
sound.addEventListener( ActionEvent.FINISH , debug ) ;
sound.addEventListener( ActionEvent.LOOP , debug ) ;
sound.addEventListener( ActionEvent.STOP , debug ) ;
sound.addEventListener( ActionEvent.START , debug ) ;
sound.volume = 0.6 ;
// sound.looping = true ;
sound.play() ;
| Property | Defined By | ||
|---|---|---|---|
| channel : SoundChannel [read-only]
The SoundChannel object of this CoreSound object. | CoreSound | ||
| DEFAULT_DELAY : uint = 150 [static]
The default delay value of the internal timer of the CoreSound objects in milliseconds. | CoreSound | ||
| finishIt : Signaler
This signal emit when the notifyFinished method is invoked. | CoreSound | ||
| leftPeak : Number [read-only]
The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude). | CoreSound | ||
| logger : Logger
Determinates the internal ILogger reference of this Logable object. | CoreSound | ||
| looping : Boolean
The flag to determinate if the Action object is looped. | CoreSound | ||
| muteIt : Signaler
This signal emit when the sound is muted. | CoreSound | ||
| pan : Number
The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right). | CoreSound | ||
| pausing : Boolean [read-only]
(read-only) Returns true if the process is in pause. | CoreSound | ||
| phase : String [read-only]
The current phase of the action. | CoreSound | ||
| position : Number [read-only]
The current position of the playhead within the sound. | CoreSound | ||
| rightPeak : Number [read-only]
The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude). | CoreSound | ||
| running : Boolean [read-only]
Returns true if the process is in progress. | CoreSound | ||
| soundTransform : SoundTransform
The SoundTransform object assigned to the sound channel. | CoreSound | ||
| startIt : Signaler
This signal emit when the notifyStarted method is invoked. | CoreSound | ||
| unmuteIt : Signaler
This signal emit when the sound is unmuted. | CoreSound | ||
| volume : Number
The volume, ranging from 0 (silent) to 1 (full volume). | CoreSound | ||
| Method | Defined By | ||
|---|---|---|---|
CoreSound(stream:URLRequest = null, context:SoundLoaderContext = null)
Creates a new CoreSound instance. | CoreSound | ||
clone():*
Returns the shallow copy of the object. | CoreSound | ||
isLocked():Boolean
Returns true if the object is locked. | CoreSound | ||
isMuted():Boolean
Returns true if the sound is muted. | CoreSound | ||
load(stream:URLRequest, context:SoundLoaderContext = null):void [override]
Initiates loading of an external MP3 file from the specified URL. | CoreSound | ||
lock():void
Locks the object. | CoreSound | ||
mute():void
Mute the sound. | CoreSound | ||
notifyFinished():void
Notify an ActionEvent when the process is finished. | CoreSound | ||
notifyStarted():void
Notify an ActionEvent when the process is started. | CoreSound | ||
pause():Boolean
Pauses playback of the Sound. | CoreSound | ||
play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannel [override]
Generates a new SoundChannel object to play back the sound. | CoreSound | ||
registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an system.events.EventListener object with an system.events.EventDispatcher object so that the listener receives notification of an event. | CoreSound | ||
resume():void
Resumes playback of the sound that is paused (if the pausing property is true). | CoreSound | ||
run(... arguments):void
Run the process. | CoreSound | ||
start():void
Stars the sound. | CoreSound | ||
stop():void
Stops the sound playing in the channel. | CoreSound | ||
togglePause():void
Pauses or resumes playback of the sound. | CoreSound | ||
toSource(indent:int = 0):String
Returns the String source representation of this object. | CoreSound | ||
unlock():void
Unlocks the sound. | CoreSound | ||
unmute():void
Unmute the sound. | CoreSound | ||
unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void
Removes an system.events.EventListener from the system.events.EventDispatcher object. | CoreSound | ||
| Method | Defined By | ||
|---|---|---|---|
notifyChange():void
Notify an ActionEvent when the process of the sound is changed. | CoreSound | ||
notifyLooped():void
Notify an ActionEvent when the process is looped. | CoreSound | ||
notifyPaused():void
Notify an ActionEvent when the process is stopped. | CoreSound | ||
notifyResumed():void
Notify an ActionEvent when the process is resumed. | CoreSound | ||
notifyStopped():void
Notify an ActionEvent when the process is stopped. | CoreSound | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when a process is finished. | CoreSound | |||
| Dispatched when a process is started. | CoreSound | |||
| channel | property |
channel:SoundChannel [read-only] The SoundChannel object of this CoreSound object.
public function get channel():SoundChannel| DEFAULT_DELAY | property |
public static var DEFAULT_DELAY:uint = 150The default delay value of the internal timer of the CoreSound objects in milliseconds.
| finishIt | property |
finishIt:SignalerThis signal emit when the notifyFinished method is invoked.
public function get finishIt():Signaler public function set finishIt(value:Signaler):void| leftPeak | property |
leftPeak:Number [read-only] The current amplitude (volume) of the left channel, from 0 (silent) to 1 (full amplitude). If the value is NaN, the internal SoundChannel is 'null'.
public function get leftPeak():Number| logger | property |
logger:Logger
Determinates the internal ILogger reference of this Logable object.
public function get logger():Logger public function set logger(value:Logger):void| looping | property |
public var looping:BooleanThe flag to determinate if the Action object is looped.
| muteIt | property |
muteIt:SignalerThis signal emit when the sound is muted.
public function get muteIt():Signaler public function set muteIt(value:Signaler):void| pan | property |
pan:NumberThe left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right). A value of 0 represents no panning (balanced center between right and left).
public function get pan():Number public function set pan(value:Number):void| pausing | property |
pausing:Boolean [read-only]
(read-only) Returns true if the process is in pause.
public function get pausing():Boolean| phase | property |
phase:String [read-only] The current phase of the action.
public function get phase():StringSee also
| position | property |
position:Number [read-only] The current position of the playhead within the sound. If the value is NaN, the internal SoundChannel is 'null'.
public function get position():Number| rightPeak | property |
rightPeak:Number [read-only] The current amplitude (volume) of the right channel, from 0 (silent) to 1 (full amplitude). If the value is NaN, the internal SoundChannel is 'null'.
public function get rightPeak():Number| running | property |
running:Boolean [read-only]
Returns true if the process is in progress.
public function get running():Boolean| soundTransform | property |
soundTransform:SoundTransformThe SoundTransform object assigned to the sound channel. A SoundTransform object includes properties for setting volume, panning, left speaker assignment, and right speaker assignment.
public function get soundTransform():SoundTransform public function set soundTransform(value:SoundTransform):void| startIt | property |
startIt:SignalerThis signal emit when the notifyStarted method is invoked.
public function get startIt():Signaler public function set startIt(value:Signaler):void| unmuteIt | property |
unmuteIt:SignalerThis signal emit when the sound is unmuted.
public function get unmuteIt():Signaler public function set unmuteIt(value:Signaler):void| volume | property |
volume:NumberThe volume, ranging from 0 (silent) to 1 (full volume).
public function get volume():Number public function set volume(value:Number):void| CoreSound | () | Constructor |
public function CoreSound(stream:URLRequest = null, context:SoundLoaderContext = null)Creates a new CoreSound instance.
Parametersstream:URLRequest (default = null) — The URL request that points to an external MP3 file.
| |
context:SoundLoaderContext (default = null) — The SoundLoaderContext Minimum number of milliseconds of MP3 data to hold in the Sound object's buffer. The Sound object waits until it has at least this much data before beginning playback and before resuming playback after a network stall. The default value is 1000 (one second).
|
| clone | () | method |
public function clone():*Returns the shallow copy of the object.
Returns* — the shallow copy of the object.
|
| isLocked | () | method |
public function isLocked():Boolean
Returns true if the object is locked.
Boolean — true if the object is locked.
|
| isMuted | () | method |
public function isMuted():Boolean
Returns true if the sound is muted.
Boolean — true if the sound is muted.
|
| load | () | method |
override public function load(stream:URLRequest, context:SoundLoaderContext = null):voidInitiates loading of an external MP3 file from the specified URL. If you provide a valid URLRequest object to the Sound constructor, the constructor calls Sound.load() for you. You only need to call Sound.load() yourself if you don't pass a valid URLRequest object to the Sound constructor or you pass a null value.
Parameters
stream:URLRequest | |
context:SoundLoaderContext (default = null) |
| lock | () | method |
public function lock():voidLocks the object.
| mute | () | method |
public function mute():voidMute the sound.
| notifyChange | () | method |
protected function notifyChange():voidNotify an ActionEvent when the process of the sound is changed.
| notifyFinished | () | method |
public function notifyFinished():voidNotify an ActionEvent when the process is finished.
| notifyLooped | () | method |
protected function notifyLooped():voidNotify an ActionEvent when the process is looped.
| notifyPaused | () | method |
protected function notifyPaused():voidNotify an ActionEvent when the process is stopped.
| notifyResumed | () | method |
protected function notifyResumed():voidNotify an ActionEvent when the process is resumed.
| notifyStarted | () | method |
public function notifyStarted():voidNotify an ActionEvent when the process is started.
| notifyStopped | () | method |
protected function notifyStopped():voidNotify an ActionEvent when the process is stopped.
| pause | () | method |
public function pause():BooleanPauses playback of the Sound.
ReturnsBoolean — true if the pause method can be use (the internal SoundChannel of this Sound object is not null and not is "pausing").
|
| play | () | method |
override public function play(startTime:Number = 0, loops:int = 0, sndTransform:SoundTransform = null):SoundChannelGenerates a new SoundChannel object to play back the sound.
Parameters
startTime:Number (default = 0) — The initial position in milliseconds at which playback should start.
| |
loops:int (default = 0) — Defines the number of times a sound loops back to the startTime value before the sound channel stops playback.
| |
sndTransform:SoundTransform (default = null) — Defines the number of times a sound loops back to the startTime value before the sound channel stops playback.
|
SoundChannel — A SoundChannel object, which you use to control the sound.
This method returns null if you have no sound card or if you run out of available sound channels.
The maximum number of sound channels available at once is 32.
|
| registerEventListener | () | method |
public function registerEventListener(type:String, listener:*, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an system.events.EventListener object with an system.events.EventDispatcher object so that the listener receives notification of an event.
Parameters
type:String | |
listener:* | |
useCapture:Boolean (default = false) | |
priority:int (default = 0) | |
useWeakReference:Boolean (default = false) |
| resume | () | method |
public function resume():void
Resumes playback of the sound that is paused (if the pausing property is true).
| run | () | method |
public function run(... arguments):voidRun the process.
Parameters
... arguments |
| start | () | method |
public function start():voidStars the sound.
| stop | () | method |
public function stop():voidStops the sound playing in the channel.
| togglePause | () | method |
public function togglePause():voidPauses or resumes playback of the sound. You could use this method to let users pause or resume playback by pressing a single button.
| toSource | () | method |
public function toSource(indent:int = 0):String
Returns the String source representation of this object.
Parameters
indent:int (default = 0) |
String — the String source representation of this object.
|
| unlock | () | method |
public function unlock():voidUnlocks the sound.
| unmute | () | method |
public function unmute():voidUnmute the sound.
| unregisterEventListener | () | method |
public function unregisterEventListener(type:String, listener:*, useCapture:Boolean = false):void
Removes an system.events.EventListener from the system.events.EventDispatcher object.
Parameters
type:String | |
listener:* | |
useCapture:Boolean (default = false) |
| finish | Event |
system.events.ActionEventsystem.events.ActionEvent.FINISHDispatched when a process is finished.
The name of the event when the process is finished.See also
| start | Event |
system.events.ActionEventsystem.events.ActionEvent.STARTDispatched when a process is started.
The name of the event when the process is started.See also