Playing Video
You can play videos running from your device or loaded remotely.
Embedded Video
You can embed a video in your application using Flash
Professional. Embedded video will appear in the library as a symbol.
Create a MovieClip
and add the
video content to it. You can then control its playback by calling the
standard MovieClip
navigation
methods.
Using this approach is simple, but it has disadvantages. The video is compiled into the application and adds to its size. Also, it is always loaded in memory and cannot be removed.
As an alternative, you can embed the video in an external
.swf file which you load using
the Loader
class.
External Video
You can package the video with your application. It is placed in the application directory. The application will not display until all of the assets are loaded. You can also serve the video from a remote web server. The code is identical in both cases.
For the latter, add some buffering logic. We will come back to this topic later in this chapter.
Progressive Video
To load video locally, you need to know the path of the file in your application directory.
NetConnection
creates a connection with the local
filesystem when calling its connect
method. Pass a null parameter in its construction to indicate that it
is not streaming.
Within the connection, NetStream
opens the channel between AIR and
the local filesystem. Pass the connection
object as a parameter in its
construction, and use its play
method to receive video data. Note that this object ...
Get Developing Android Applications with Adobe AIR now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.