Use the constants defined in this class as input to the
A Camera instance captures video in landscape aspect ratio. On devices that can change the screen orientation, such as mobile phones, a Video object attached to the camera will only show upright video in a landscape-aspect orientation. Thus, mobile apps should use a landscape orientation when displaying video and should not auto-rotate.
As of AIR 2.6, autofocus is enabled automatically on mobile devices with an autofocus camera. If the camera does not support continuous autofocus,
and many mobile device cameras do not, then the camera is focused when the Camera object is attached to a video stream and whenever
the
In an AIR application on Android and iOS, the camera does not capture video while an AIR app is not the active, foreground application. In addition, streaming connections can be lost when the application is in the background. On iOS, the camera video cannot be displayed when an application uses the GPU rendering mode. The camera video can still be streamed to a server.
Mobile Browser Support: This class is not supported in mobile browsers.
AIR profile support: This feature is supported
on desktop operating systems, but it is not supported on all mobile devices. It is not
supported on AIR for TV devices. See
You can test
for support at run time using the
For information about capturing audio, see the Microphone class.
Important: Flash Player displays a Privacy dialog box that lets the user choose whether to allow or deny access to the camera. Make sure your application window size is at least 215 x 138 pixels; this is the minimum size required to display the dialog box.
To create or reference a Camera object, use the
Note: A camera must be attached to your computer for this example to work correctly.
Multiple calls to the
On iOS devices with a both a front- and a rear-facing camera, you can only capture video from one camera at a time. On Android devices, you can only access the rear-facing camera.
In general, you shouldn't pass a value for the
You can't use ActionScript to set a user's Allow or Deny permission setting
for access to the camera, but you can display the Adobe Flash Player Settings camera
setting dialog box where the user can set the camera permission. When a SWF file using
the
In Flash Player, the user can specify permanent privacy settings for a particular domain by right-clicking (Windows and Linux) or Control-clicking (Macintosh) while a SWF file is playing, selecting Settings, opening the Privacy dialog, and selecting Remember. If the user selects Remember, Flash Player no longer asks the user whether to allow or deny SWF files from this domain access to your camera.
Note: The
If
Scanning the hardware for cameras takes time. When the runtime finds at least one camera,
the hardware is not scanned again for the lifetime of the player instance. However, if
the runtime doesn't find any cameras, it will scan each time
The
Usually, when the
The
The
A Timer object also is started. Every second, a Timer object's timer event is dispatched and the
Note: For this example, the only property that changes
is the
The Flash Video compression algorithm compresses video by transmitting only what has changed since the last frame of the video; these portions are considered to be interpolated frames. Frames of a video can be interpolated according to the contents of the previous frame. A keyframe, however, is a video frame that is complete; it is not interpolated from prior frames.
To determine how to set a value for the
Conversely, specifying a lower value for
Although a compressed stream is useful for testing purposes, such as previewing video quality settings, it has a significant processing cost, because the local view is not simply compressed; it is compressed, edited for transmission as it would be over a live connection, and then decompressed for local viewing.
To set the amount of compression used when you set
By default, Flash Player drops frames as needed to maintain image size. To minimize the number
of dropped frames, even if this means reducing the size of the image, pass
When choosing a native mode, Flash Player tries to maintain the requested aspect ratio
whenever possible. For example, if you issue the command
To determine the values assigned to these properties after Flash Player selects the mode
that most closely matches your requested values, use the
If you are using Flash Media Server, you can also capture single frames or create time-lapse
photography. For more information, see
The Stage is set so it does not scale. The
Note: Video can be displayed regardless of the value of the
To prevent the camera from detecting motion at all, pass a value of 100 for the
To determine the amount of motion the camera is currently detecting, use the
This method is similar in purpose to the
The
The
Use this method to specify which element of the outgoing video feed is more important to your application—bandwidth use or picture quality.
If the camera is available but is not yet being used because the
If you are streaming only uncompressed local video, this property is set only if you have assigned a function to the event handler. Otherwise, it is undefined.
To set this property, use the
Although a compressed stream is useful for testing, such as when previewing video quality settings, it has a significant processing cost. The local view is compressed, edited for transmission as it would be over a live connection, and then decompressed for local viewing.
To set this value, use
Video can be displayed regardless of the value of the
To set this value, use
Calling the
On Android, only one camera is supported, even if the device has more than one camera devices. The name of the camera is always, "Default."
To set this property, use the
In the constructor, the sound is loaded and is assigned to a sound channel
(
Note: There is limited error handling written for this example.
The StageWebView class provides a simple means to display HTML content on devices where the HTMLLoader class is not supported. The class provides no interaction between ActionScript and the HTML content except through the methods and properties of the StageWebView class itself. There is, for example, no way to pass values or call functions between ActionScript and JavaScript.
AIR profile support: This feature is supported
on all desktop operating systems and mobile devices, but is not supported on AIR for TV devices. You can test
for support at run time using the
On devices in the mobile and extended mobile profiles, the StageWebView class uses
the system web control provided by the device operating system. Thus, the available
features and rendering appearance may vary from device to device. On desktop computers (in the
desktop and extended desktop profiles), the StageWebView class uses the internal AIR
WebKit engine. The features available and rendering appearance are the same as those of the
HTMLLoader class (without the close integration and script bridging between ActionScript and
JavaScript provided by an HTMLLoader instance). Test the
The StageWebView class is NOT a display object and cannot be added to the Flash display list.
Instead you display a StageWebView object by attaching it directly to a stage using the
When the content within the StageWebView object has focus, the StageWebView object has the first opportunity to handle keyboard input. The stage to which the StageWebView object is attached dispatches any keyboard input that is not handled. The normal event capture/bubble cycle does not apply here since the StageWebView instance is not part of the display list.
In Android 3.0+, an application must enable hardware acceleration in the Android manifestAdditions element of the AIR application descriptor to display plug-in content in a StageWebView object.
A locationChanging event is only dispatched when the location change is initiated through
HTML content or code running inside the StageWebView object,such as when a user clicks a link.
By default, the new location is displayed in this
StageWebView object. You can call the
A locationChanging event is not dispatched when you change the location with the following methods:
The event cannot be canceled.
The object is invisible until it is attached to a stage and until the
Direction values are defined in FocusDirection class and include: "bottom", "none", and "top".
Calling
Capture the bitmap and set the stage to
When the
The HTML content cannot load local resources, such as image files. XMLHttpRequests are not allowed.
Only the "text/html" and "application/xhtml+xml" MIME types are supported.
The URL can use the following URI schemes: http:, https:, file:, data:, and javascript:. Content loaded with the file: scheme can load other local resources.
Note: On Android, you must specify the INTERNET permission in your AIR application descriptor to load remote URLs.
Set
The
You cannot create a MediaPromise object. Calling
A
The
If the underlying data source is asynchronous, then the MediaPromise object dispatches
Note: You can load a MediaPromise object using the
Application code should not call this method.
This property references a File object if the underlying data source is file-based and the
file is accessible to your application.
Otherwise, the property is
The constants in the MediaType class define possible values of this property:
A file name is available if the underlying data source is file-based and the
file is accessible to your application.
Otherwise, the property is
When you use this class, consider the following security model:
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
The first parameter of a SoundLoaderContext object (
Note that you cannot override the value of
Set this property to
If you don't need low-level access to the sound data that you are loading, avoid setting
When you call
In all cases, Flash Player or AIR
requires that an appropriate policy file exist on the sound's server, that it provide access
to the sound file at
If you set
If you set
Be careful with
If you find yourself in this situation, here is one possible solution.
After you receive a
This does not apply to content in the AIR application sandbox. Content in the application sandbox always has programatic access to sound content, regardless of its origin.
For more information related to security, see the Flash Player Developer Center Topic:
In the constructor, a text field is defined that holds the song list
and a line for the selection to play. (Usually, buttons are
used for play and list boxes for a song list.) A text format object is
defined that changes the format of the song lines to italic after they are
selected. When a user selects the text field, the
In the
The
In the constructor, the sound file is loaded. (This example assumes that the file is
in the same directory as the SWF file.) A text field is used as a button for the user
to play or pause the sound. When the user selects the
In the
A common use case is to save the value of the
If the sound is looped,
For AIR application content in the application security sandbox, calling this method always
returns
Note: This method is subject to local file security restrictions and restrictions on cross-domain loading. If you are working with local files or sounds loaded from a server in a different domain than the calling content, you might need to address sandbox restrictions through a cross-domain policy file. For more information, see the Sound class description. In addition, this method cannot be used to extract data from RTMP streams, even when it is called by content that reside in the same domain as the RTMP server.
This method is supported over RTMP in Flash Player 9.0.115.0
and later and in Adobe AIR. You can control access to streams on
Flash Media Server in a server-side script. For more information, see the
In the constructor, a sound file is loaded and set to play. (There is no error handling
in this example and it is assumed that the sound file is in the same directory as the SWF file.)
The example listens for the
In the
>In Flash Professional, this method does not stop the playhead. Sounds set to stream will resume playing as the playhead moves over the frames in which they are located.
When using this property, consider the following security model:
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
In the constructor, two different sound files are loaded and set to play. The first sound is
loaded locally and is assigned to a sound channel. (It is assumed that the file is
in the same directory as the SWF file.) The second file is loaded and streamed from the Adobe
site. In order to use the
In the
The
The
On some platforms, the media object returned by the camera is accessible as a file-based media promise. On others,
the media promise is not file-based and the
On some platforms, the media object is automatically stored in the device media library. On those
platforms on which images and video are not automatically stored by the default camera application, you can use the
CameraRoll
On Android, the default camera application does not open if the external storage card is not available (such as when the user has mounted the card as a USB mass storage device). In addition, the AIR application that launches the camera loses focus. If the device runs low on resources, the AIR application can be terminated by the operating system before the media capture is complete.
AIR profile support: This feature is supported
on mobile devices, but it is not supported on desktop operating systems or AIR for TV devices. You can test
for support at run time using the
You can capture either still images or video with this class. Video capture uses the "Quality Low" camcorder profile on the device.
When the
Note: It is possible for the AIR application to be shut down by the Android operating system while it is in the background waiting for the user to capture an image or video. If this happens, the user must restart the application. The AIR application does not dispatch a media event for the previous image capture.
You can access the captured media file using the
AIR profile support: This feature is supported
on mobile devices, but it is not supported on desktop operating systems or AIR for TV devices. See
The
The
The MediaEvent object dispatched for this event provides access to the chosen media.
Sources of errors include:
There is only a single media library supported by ActionScript. All CameraRoll objects save to the same image repository.
To check at run time whether your application supports the
When the user selects an image, this CameraRoll instance dispatches a
To check at run time whether your application supports the
To get a reference to a Microphone instance, use the
Create a real-time chat application
To create a real-time chat application, capture audio and send it to Flash Media Server.
Use the NetConnection and NetStream classes to send the audio stream to Flash Media Server.
Flash Media Server can broadcast the audio to other clients.
To create a chat application that doesn't require headsets, use acoustic echo
cancellation. Acoustic echo cancellation prevents the feedback loop that occurs when audio enters a microphone,
travels out the speakers, and enters the microphone again. To use acoustic echo cancellation, call
the
Play microphone audio locally
Call the Microphone
Capture microphone audio for local recording or processing
To capture microphone audio, listen for the
For information about capturing video, see the Camera class.
Runtime microphone support
The Microphone class is not supported in Flash Player running in a mobile browser.
AIR profile support: The Microphone class is supported
on desktop operating systems, but it is not supported on all mobile devices.
It is not supported on AIR for TV devices. See
You can test for support at run time using the
Privacy controls
Flash Player displays a Privacy dialog box that lets the user choose whether to allow or deny access to the microphone. Your application window size must be at least 215 x 138 pixels, the minimum size required to display the dialog box, or access is denied automatically.
Content running in the AIR application sandbox does not need permission to access the microphone and no dialog is displayed. AIR content running outside the application sandbox does require permission and the Privacy dialog is displayed.
Two listeners listen for
Note: A microphone must be attached to your computer for this example to work correctly.
Status events are not dispatched in Adobe AIR applications; access to the microphone cannot be changed dynamically. On most platforms, AIR applications can always access the microphone. On Android, an application must specify the Android RECORD_AUDIO permission in the application descriptor. Otherwise, Android denies access to the microphone altogether.
The
Two listeners listen for
Note: A microphone must be attached to your computer for this example to work correctly.
To specify the amount of sound required to trigger this event
with an
For a Microphone object to dispatch activity events, the application must be monitoring
the input, either by calling
The
Important: At any given time you can have only a single instance of enhanced microphone device.
All other Microphone instances stop providing audio data and receive a
To configure an enhanced Microphone object, set the
var mic:Microphone = Microphone.getEnhancedMicrophone(); var options:MicrophoneEnhancedOptions = new MicrophoneEnhancedOptions(); options.mode = MicrophoneEnhancedMode.FULL_DUPLEX; mic.enhancedOptions = options; mic.setLoopBack(true);
The
When a SWF file tries to access the object returned by
Multiple calls to
In general, you should not pass a value for
Use the
When a SWF file tries to access the object returned by
When the user responds to this dialog box, a
If
Speex includes voice activity detection (VAD) and automatically reduces bandwidth when no voice is detected. When using the Speex codec, Adobe recommends that you set the silence level to 0.
Activity detection is the ability to detect when audio levels suggest that a person is talking. When someone is not talking, bandwidth can be saved because there is no need to send the associated audio stream. This information can also be used for visual feedback so that users know they (or others) are silent.
Silence values correspond directly to activity values. Complete silence is an activity value of 0. Constant loud noise (as loud as can be registered based on the current gain setting) is an activity value of 100. After gain is appropriately adjusted, your activity value is less than your silence value when you're not talking; when you are talking, the activity value exceeds your silence value.
This method is similar to
Echo suppression is an effort to reduce the effects of audio feedback, which is caused when
sound going out the speaker is picked up by the microphone on the same system. (This is different
from acoustic echo cancellation, which completely removes the feedback. The
Generally, echo suppression is advisable when the sound being captured is played through
speakers — instead of a headset —. If your SWF file allows users to specify the
sound output device, you may want to call
Users can also adjust these settings in the Flash Player Microphone Settings panel.
If the microphone
If you use the Nellymoser codec, you can set the sample rate using
Speex includes voice activity detection (VAD) and automatically reduces bandwidth when no voice is detected.
When using the Speex codec, Adobe recommends that you set the silence level to 0. To set the silence level, use the
The more Speex frames in a message, the lower the bandwidth required but the longer the delay in sending the message. Fewer Speex frames increases bandwidth required but reduces delay.
Calling
Note: To determine the name of the current microphone,
use the
Note: The actual rate differs slightly from the
To set this value, use the
AIR profile support: In AIR 2.5, this feature is supported
only on devices that run AIR for TV. See
The video displayed by the StageVideo object always appears in a rectangular area on the stage behind all Flash display list objects. Therefore, the StageVideo object takes advantage of hardware acceleration while supporting the most common case for displaying video: a rectangular display area overlaid with video controls.
The benefits to using a StageVideo object instead of the Video object are:
Because the StageVideo object uses device hardware capabilities, a StageVideo object is subject to the following constraints compared to a Video object:
The following steps summarize how to use a StageVideo object to play a video:
If a
If a running video goes into full screen mode from a WMODE that does not support stage video, stage video can become available. Likewise, if the user exits full screen mode, stage video can become unavailable. In these cases, the Stage.stageVideos vector changes. To receive notification of this change, listen to the StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABITY event. NOTE: This notification is not available in AIR 2.5 for TV.
Before calling
You do not need to use this method if a video file contains only audio; the audio
portion of a video file is played automatically
when you call
Note: On AIR for TV devices, a value of "BT.601" indicates software playback, and a value of "BT.709" indicates hardware playback.
StageVideo objects always display behind other objects on the stage. If a platform supports more than one
StageVideo object, the
Note: AIR for TV devices support only one StageVideo object. Therefore, this property is not applicable for those devices. It is a placeholder for future support on other devices.
By default, the value of
The
The valid values of the
Values between -1.0 and 1.0 pan according to scale.
If you set the
Also, consider that to use a StageVideo object, you assign an element
of the
You may want to use this property, for example, to ensure that the user is seeing the
video at the same height at which it was captured,
regardless of the size of the
You may want to use this property, for example, to ensure that the user is seeing the
video at the same width at which it was captured,
regardless of the size of the
The position of the video is relative to the upper left corner of the stage.
The valid range of the
The zoom point is a scale factor. By default, the value of
The valid values of the
For example, a
When you set the
Consider the following situation where it is useful to set a different value for the
If you set the
Also, consider that to use a StageVideo object, you assign an element
of the
To use acoustic echo cancellation, call
Possible values are:
In Flash Player 10 and later and AIR 1.5 and later, you can also use this
class to work with sound that is generated dynamically.
In this case, the Sound object uses the function you assign to a
To control sounds that are embedded in a SWF file, use the properties in the SoundMixer class.
Note: The ActionScript 3.0 Sound API differs from ActionScript 2.0. In ActionScript 3.0, you cannot take sound objects and arrange them in a hierarchy to control their properties.
When you use this class, consider the following security model:
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
Once
In the constructor, a text field is created for the Start and Stop button.
When the user clicks on the text field, the
This method is designed to be used when you are working
with dynamically generated audio, using a function you assign
to the
The audio data is placed in the target byte array starting from the current position of the byte array.
The audio data is always exposed as 44100 Hz Stereo. The sample type is a 32-bit floating-point value,
which can be converted to a Number using
The mp3 data is loaded into the
To test this example, add a test.mp3 file to the same directory as the SWF file.
Once
When using this method, consider the following security model:
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
In Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
In the constructor a
The
The constructor calls the
In the
In the constructor, the sound is loaded and a simple rectangle
Two event listeners are set up to respond to single mouse clicks and double clicks.
If the user clicks once, the
In the constructor, the file is loaded in a
The
Note that if the file is small, cached, or the file is in the local directory, the load progress
may not be noticeable. Also the lag time between when the sound data starts loading and the loaded
data starts playing is determined by the value of the
MP3 sound files can contain ID3 tags, which provide metadata about the
file. If an MP3 sound that you load using the
The following table describes ID3 tags that are supported but do not have
predefined properties in the Sound class. You access them by calling
When using this property, consider the Flash Player security model:
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
In the constructor, the sound file is loaded but it is not set to play. Here, it is
assumed that the file is in the SWF directory. The system must have permission
in order to read the ID3 tags of a loaded sound file. If there is ID3 information in
the file and the program is permitted to read it, an
In the
Note that no error handling is written for this example and if the ID3 content is long, the result may go beyond the viewable area.
Note: The
For application content in AIR, the value of this property is always
When you first call
The
In some cases, the value of the
If the application uses the default
When used with Flash Media Server, the Video object allows you to send live video captured by a user to the server and then broadcast it from the server to other users. Using these features, you can develop media applications such as a simple video player, a video player with multipoint publishing from one server to another, or a video sharing application for a user community.
Flash Player 9 and later supports publishing and playback of FLV files encoded with either the Sorenson Spark or On2 VP6 codec and also supports an alpha channel. The On2 VP6 video codec uses less bandwidth than older technologies and offers additional deblocking and deringing filters. See the flash.net.NetStream class for more information about video playback and supported formats.
Flash Player 9.0.115.0 and later supports mipmapping to optimize runtime rendering quality and performance.
For video playback, Flash Player uses mipmapping optimization if you set the Video object's
As with other display objects on the display list,
you can control various properties of Video objects. For example,
you can move the Video object around on the Stage by using its
To play a video stream, use
If you are using Flash Professional, you can also place the Video object on the Stage
rather than adding it with
In AIR applications on the desktop, playing video in fullscreen mode disables any power and screen saving features (when allowed by the operating system).
Note:
The Video class is not a subclass of the InteractiveObject class, so
it cannot dispatch mouse events. However, you can call the
In this example, the code that creates the Video and NetStream objects and calls
After creating the Video, call the
Use this method to attach live video captured by the user to the Video object. You can play the live video locally on the same computer or device on which it is being captured, or you can send it to Flash Media Server and use the server to stream it to other users.
Note: In an iOS AIR application, camera video cannot be displayed when the application uses GPU rendering mode.
You do not need to use this method if a video file contains only audio; the audio
portion of video files is played automatically
when you call
Compression of video can result in undesired artifacts. You can use the
Blocking refers to visible imperfections between the boundaries of the blocks that compose each video frame. Ringing refers to distorted edges around elements within a video image.
Two deblocking filters are available: one in the Sorenson codec and one in the On2 VP6 codec. In addition, a deringing filter is available when you use the On2 VP6 codec. To set a filter, use one of the following values:
If a value greater than 2 is selected for video when you are using the Sorenson codec, the Sorenson decoder defaults to 2.
Using a deblocking filter has an effect on overall playback performance, and it is usually not necessary for high-bandwidth video. If a user's system is not powerful enough, the user may experience difficulties playing back video with a deblocking filter enabled.
For video playback using Flash Player 9.0.115.0 and later versions, set this property to
You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.
You may want to use this property, for example, to ensure that the user is seeing the video at the same size at which it was captured, regardless of the actual size of the Video object on the Stage.