Often, you'll need to use a video or video-like effects in your project. Or, you'll want to create a standalone video player with your own user interface. Also, many clients will want Flash MX-like effects; this section addresses some of the many video-in-Flash techniques. Windows Media Playeron the Pocket PCIncluded on almost all Pocket PC 2002 devices is the Windows Media Player 8 for Pocket PC (see Figure 2.19). Figure 2.19. The Windows Media Player for Pocket PC playing a video.
Windows Media Player supports the organization and playback of Windows Media content through play lists, MP3 audio files, Windows Media Audio, Windows Media Video, FhG MP3, and streamed content in Windows Media format using WM protocols (HTTP and MMS). Most desktop users (over 70%) currently use the Windows Media Player and they're already familiar with the interface, so in most cases using the Windows Media Player for video is often the best choice. If the user has Windows Media Player 7 or above on his PC, he can use it to easily transfer digital media files to his Pocket PC (see Figure 2.20). Figure 2.20. The desktop Windows Media Player.
Also, with a wave of digital rights based content, users will soon be playing more content that has been purchased, such as music. Flash works well with other applications, just like the desktop, so it's important to start planning for what is to come with engaging combinations of Flash and Windows media content for the Pocket PC.
Launching a Windows Media file from Flash on the Pocket PC is as simple as linking to a file via getURL . For example: on (press) { getURL ("video.wmv"); } After the user is finished with the video and closes out of the application, it will return the user to the page he just came from. Actually, let's be a little more specific and mention a few caveats. "Closing" an application on the Pocket PC is actually just placing it in the background. So if you have any sounds or animations in your Flash application on the Pocket PC, be sure to stop the animations and sounds when launching a user to another application. This can be accomplished by using the stop (); command on the timeline and stopAllSounds (); in the movie. In fact, this is why it's usually a good idea not to have a background track running or intense animations at all times, or to create a timeout. You can also quit almost any application on the Pocket PC by using the built-in keyboard. To quit an application with the built-in keyboard, tap Ctrl and then the Q key (just like the desktop) and that closes most applications, including Internet Explorer for the Pocket PC. If you plan to open extremely large documents from Pocket Internet Explorer, you may want to consider deploying an additional ActiveX control with your application if it's permitted. The AppLaunch ActiveX Control from Microsoft makes it possible to open large files more quickly in Internet Explorer for the Pocket PC. It bypasses the temporary cache, resulting in a faster launch of the application launching as if it is in File Explorer. To download the ActiveX control, visit: www.microsoft.com/mobile/developer/downloads/powertoys.asp. To use this ActiveX control within Flash, call the JavaScript function from within Flash (be sure to consult the ActiveX control documentation as well). To call the AppLaunch Active Control, add the following action to a button inside Flash: on (press) { getURL ("javascript:LaunchMe();"); } In this HTML file you have the script that's ready to be called: <HTML> <HEAD> <TITLE>exe_tester</TITLE> </HEAD> <BODY bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <SCRIPT LANGUAGE="JScript"> function LaunchMe() { var Launch; var ExeName = "\\windows\\player.exe"; var ExeParam = "\\My Documents\\video.wmv"; Launch = new ActiveXObject("AppLaunch.Launch"); Launch.ExeName = ExeName; Launch.ExeParam = ExeParam; Launch.Run(); // Launches "player.exe" with "video.wmv" as a parameter } </script> <CENTER> <OBJECT class codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" ID=PocketPC WIDTH=240 HEIGHT=240> <PARAM NAME=movie VALUE="exe_tester.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF> </OBJECT> </CENTER> </BODY> </HTML> We've included this example on the Flashenabled.com/book site if you need to take a closer look at it.
Video Inside Flash on the Pocket PCIn some cases you may decide that the Windows Media Player for Pocket PC doesn't have the level of control that your application requires. For those instances, as well as design projects which may require "video-like" effects, here are two ways to get Flash content to play video on the Pocket PC. Importing a Sequence of Bitmap ImagesThe first technique is basically importing a sequence of bitmap images in a series of keyframes to simulate video. Usually, you import the video into Flash first, export it as a bitmap sequence, then import it back in (with sound track imported as well). Flash will do a pretty good job of making short video clips (usually a few seconds) fairly video-like. Let's create a short video clip. Set up your movie, 240x240, 12 frames per second, with a white background.
Test your movie (Control, Test Movie). In Publish Settings (File, Publish Settings) under the Flash tab you can adjust the JPEG settings to make the movie smaller or larger in file size and memory. The technique of using imported bitmaps is good in some cases, but be aware that this is extremely memory intensive and can cause the Flash Player for Pocket PC to crash.
Video with Wildform FlixThe other method of using video inside Flash for the Pocket PC is to use a third-party tool such as Wildform Flix (www.wildform.com). With Wildform, you can avoid 99% of the work of the previously described technique, and get results that are much better (and smaller). Flix is the best video-to-SWF (Flash movie) encoder. It is the most stable, has the best quality, converts the most file types, is available for both PC and Mac, offers great support and resources, and it comes with discounts on royalty free video from the Wildform Video Library (which is useful if you need quick content for your projects). Using Flix, you can also save encoding profiles specifically for the Pocket PC (much like the Windows Media Encoder). Flix converts the following video formats into Flash movies: .mov, .qt, .dv, .avi, .mpeg (PC Only), .wmv, .asf. The Flix screen is shown in Figure 2.25. Figure 2.25. Wildform Flix is the best video-to-SWF encoder.
Using Flix, encoding video for use in Flash only involves three steps:
At the main Wildform web site, there is a fully functioning demo of Flix. There are tons of sample movies and custom players to try out. After creating Flash movies with Flix, you can load them into your Flash movie using loadMovie : loadMovieNum ("myvideo.swf", 0); loadMovie ("myvideo.swf", "holder"); On the Flashenabled.com site we've included a few samples and source files for integrating video SWFs from Flix into Flash for Pocket PC applications. As with the first video-in Flash-technique, using large SWFs with bitmaps and sounds can cause the Flash Player for Pocket PC to bring the processor to its knees. Proper testing and planning will prevent your applications from crashing or causing sluggish performance. In the next section, we'll explore ways to manage memory in and out of Flash for the Pocket PC. |