The
following sound-related ActionScript 3.0 APIs have security restrictions:
-
The
SoundMixer.computeSpectrum()
method—Always
permitted for code running in the same security sandbox as the sound
file. For code running in other sandboxes, there are security checks.
-
The
SoundMixer.stopAll()
method—Always permitted
for code running in the same security sandbox as the sound file.
For files in other sandboxes, there are security checks.
-
The
id3
property of the Sound class—Always
permitted for SWF files that are in the same security sandbox as
the sound file. For code running in other sandboxes, there are security
checks.
Every sound has two kinds of sandboxes associated with it—a content
sandbox and an owner sandbox:
-
The origin domain for the sound determines the content
sandbox, and this determines whether data can be extracted from
the sound via the
id3
property of the sound and
the
SoundMixer.computeSpectrum()
method.
-
The object that started the sound playing determines the
owner sandbox, and this determines whether the sound can be stopped
using the
SoundMixer.stopAll()
method.
When you load the sound using the
load()
method
of the Sound class, you can specify a
context
parameter,
which is a SoundLoaderContext object. If you set the
checkPolicyFile
property
of the SoundLoaderContext object to
true
, the runtime
checks for a URL policy file on the server from which the sound
is loaded. If there is a policy file, and the file permits the domain
of the loading code, the code is allowed to access the
id
property
of the Sound object; otherwise, it will not. Also, setting the
checkPolicyFile
property
can enable the
SoundMixer.computeSpectrum()
method
for loaded sounds.
You can use the
SoundMixer.areSoundsInaccessible()
method
to find out whether a call to the
SoundMixer.stopAll()
method
would not stop all sounds because the sandbox of one or more sound
owners is inaccessible to the caller.
Calling the
SoundMixer.stopAll()
method stops
those sounds whose owner sandbox is the same as that of the caller
of
stopAll()
. It also stops those sounds whose
playback was started by SWF files that have called the
Security.allowDomain()
method
to permit access by the domain of the SWF file calling the
stopAll()
method.
Any other sounds are not stopped, and the presence of such sounds
can be revealed by calling the
SoundMixer.areSoundsInaccessible()
method.
Calling the
computeSpectrum()
method
requires that every sound that is playing be either from the same
sandbox as the object calling the method or from a source that has
granted permission to the caller's sandbox; otherwise, a SecurityError
exception is thrown. For sounds that were loaded from embedded sounds
in a library in a SWF file, permission is granted with a call to
the
Security.allowDomain()
method in the loaded
SWF file. For sounds loaded from sources other than SWF files (originating
from loaded mp3 files or from video files), a URL policy file on
the source server grants access to data in loaded media.
For more information, see
Author (developer) controls
and
Website controls (policy files)
.
To
access sound data from RTMP streams, you must allow access on the
server. Use the Server-Side ActionScript
Client.audioSampleAccess
property
to allow access to specific directories on Flash Media Server. For
more information, see the
Server-Side ActionScript Language Reference
.