19 November 2007
Beginning
With the release of Flash Lite 3.0, the future of Flash applications on mobile devices becomes more promising. The next generation of mobile devices makes it possible for developers to build some really amazing apps, due to the increasing number of mobile devices that support Flash Lite or (in some cases) the new features in Flash Lite 3.0.
Flash Lite 3.0 includes new features and enhancements and extends your ability to create many types of mobile content—including screensavers, wallpapers and stand-alone applications. In this article, I'll focus on the new extended feature for FLV support. This new feature allows users to play FLV video content locally, from an HTTP location or streaming, from Flash Media Server. Flash Lite 3.0 also supports the same video codecs (On2 VP6 and Sorenson Spark) that you'll find in the Flash authoring environment.
In this article, I'll provide examples of how to create video content for mobile devices. We'll focus on two strategies: The 3GP mobile video format and FLV video format. The examples in this article focus on playing video content locally.
Along the way, I'll also point out the workflow integration between CS3 products and offer recommendations on using the tools included in Creative Suite 3 to create mobile video content without requiring any other third-party applications.
As we get started, I'll illustrate how you can navigate files and resources using Adobe Bridge. I'll describe the process of using Flash to create the video content and then I'll provide instructions for encoding the video into FLV format using either Flash or Adobe After Effects. I'll also show you how to use After Effects to create 3GP mobile video formats and how to create a Flash Lite file that includes video content. At the end, I'll demonstrate how to test your mobile content using Adobe Device Central.
Adobe Creative Suite 3 includes deep integration between products. Adobe Bridge 2 makes it easy to manage resources on your local machine and open each file in its default program. In this section, we'll navigate to a Flash animation and open it in Flash using Bridge. Follow these steps:
Many devices available today support Flash Lite 2.0. In this example we'll see how easy it is to create 3GP mobile video content for Flash Lite 2.0 applications:
Since we're using After Effects, we'll take advantage of the 3D effect feature to add depth to the animation before exporting it. In this section, we'll see how to apply the 3D effect and create timeline animation. Follow these steps:
Now we're ready to export our video animation as a 3GP mobile video using the Export 3GP video feature. Choose File > Export to access the 3GP Export Settings dialog box, where you can select settings for the following options:
In this section we'll create a Flash Lite 2.0 file using Adobe Device Central and we'll select the corresponding mobile device profile to use for testing the File Lite content. In this example, we'll use the Nokia N95 profile to build our Flash Lite video file. Follow these steps:
fscommand2("SetSoftKeys", "Home", "Pause");
mobileVideo.play();
var playing:Boolean = true;
Key.removeListener(myListener);
var myListener:Object = new Object();
myListener.onKeyDown = function() {
var keyCode = Key.getCode();
if (keyCode == ExtendedKey.SOFT1) {
gotoAndPlay("home");
} else if (keyCode == ExtendedKey.SOFT2) {
if (playing == true) {
mobileVideo.pause();
playing = false;
rightSoftKeyLabel.text = "Play";
} else {
mobileVideo.resume();
playing = true;
rightSoftKeyLabel.text = "Pause";
}
}
};
Key.addListener(myListener);
mobileVideo.onStatus = function(infoObject:Object) {
var code = infoObject.code;
if (code == "completed")
{
playing = false;
rightSoftKeyLabel.text = "Replay";
}
};
stop();
There are several ways to create a video file in FLV format. You can use After Effects to export an animation as FLV video. You can also use the Flash Video Encoder that is included with Flash CS3 Professional to encode video files into the FLV format.
First we'll explore using Flash and the Flash Video Encoder to create FLV video files for use on mobile devices. To begin, we'll need to export a Flash animation as QuickTime video. Follow these steps:
Note: If you've worked with previous versions of Flash and attempted to export QuickTime video in the past, you may have noticed that the exported videos did not include any animation nested inside movie clips. The new QuickTime Export feature included in Flash CS3 has been updated—animation located inside movie clip symbols is now exported and included in the MOV file.
The second method for creating FLV video files involves exporting the FLV file from Adobe After Effects CS3 Professional. Follow these steps:
As mentioned previously, Flash Lite 3.0 allows you to play FLV content from the device's local memory, HTTP location or streaming from Flash Media Server. In this section, I'll describe how to play FLV video content locally from the device's local memory. Follow these steps:
stop(); code to Frame 1. Back in the Timeline, select Frame 2 of the actionscript layer. Return to the Actions panel again and type or copy/paste the following code into the Script window to control playback of the video programmatically:video_play.attachVideo(str);
stop();
fscommand2("SetSoftKeys", "", "Exit");
var conVideo:NetConnection;
var str:NetStream;
var check:Number;
var videos:String = "test01.flv";
var tmpObj:Object = {};
stop();
tmpObj.onKeyDown = function():Void {
if (Key.getCode() == ExtendedKey.SOFT2) {
fscommand2("Quit");
return;
}
if (Key.getCode() == ExtendedKey.SOFT1) {
playVideo(videos);
}
};
Key.addListener(tmpObj);
function playVideo(file:String):Void {
if (!conVideo) {
conVideo = new NetConnection();
conVideo.connect(null);
}
if (!str) {
str = new NetStream(conVideo);
}
str.play(file);
video_mc.str = str;
video_mc.play();
Note: This code assumes that the FLV video and the Flash SWF file are located in the same folder. If you wish to relocate the FLV file to a different location, you can update the code to specify the FLV file's path.
Flash offers the option to test your application on the selected device profile by choosing Control > Test Movie. Since we've selected a mobile device profile, Flash opens Adobe Device Central, which is essentially an emulator for the mobile device. In addition to emulating your project as it will display on the selected device, Device Central provides detailed information about the mobile device's capabilities, memory, performance, status, etc. in the right panel and in the left top Device Set panel. You can save your favorite devices or add a new device set to help streamline your workflow.
The emulator in Device Central gives you the interactivity needed to test your file on the mobile device (see Figure 8) by simulating the mobile device functionality—including the key navigations. The only action the emulator does not support is the fscommand, which must be tested directly on the device. However, it is always recommended that you test your application or animation on an actual mobile device as the final testing process, in addition to using Device Central to test the content.
The Flash Lite industry is quickly growing due to the new features available and the increasing number of devices that support Flash. Flash Lite development opens new horizons for many new application ideas. It is an exciting time for mobile developers and with practice you can find a niche working with the newest trends of the market and new mobile customers. To research further, check out the Flash Lite 3.0 features and enhancements.
Also be sure to check out the following two articles to get a deeper understanding of the Flash Lite 2.0 and 3.0 ActionScript used to load video inside Flash Lite applications:
In addition to the articles listed above, here are some other useful articles that concern with working with video content in Flash Lite and using Adobe Device Central: