Recipe 3.10. Detecting the Device's Video CapabilitiesProblemYou want to determine the video capabilities of the device on which the Flash Player is running. SolutionUse the hasEmbeddedVideo, hasStreamingVideo, and hasVideoEncoder properties of the flash.system.Capabilities class. DiscussionBefore you attempt to deliver video content to a user, it is important to check whether his system is capable of playing video, and how it should be delivered. The most efficient way to deliver Flash video is to stream it to the player. This allows the user to view the video as it is coming in, rather than waiting until the entire (often quite large) file has downloaded. However, the user's system may not be capable of receiving streaming video. To check this, use the flash.system.Capabilities.hasStreamingVideo property. If this returns false, one option is to have the player load another .swf that contains an embedded video. However, before doing this, you should check the property flash.system.Capabilities.hasEbeddedVideo to ensure that the user can view this content before initiating this download. Your code would look something like this: if(flash.system.Capabilities.hasStreamingVideo) { // Code to set up a video stream and start streaming a // specific video } else if(flash.system.Capabilities.hasEmbeddedVideo) { // Code to load an external .swf containing an embedded video } else { // Alternate content without any video } Similarly, if your application requires video stream encoding, such as the use of a web cam to transmit live video from the user's system, you want to ensure that the system is capable of doing such encoding. You can test this with the flash.system.Capabilities.hasVideoEncoder property. Like the earlier example, you would probably test this property in an if statement and set up the video streaming only if it tested TRue. Otherwise, you could display a message to the user explaining the situation or redirect him to another page. |