Posts tagged "AIR for TV"

Filesystem access in an AIR for TV app

If you are writing or planning to write apps for AIR 2.5 for TV, you’ve probably already been looking at the documents and tutorials on http://www.adobe.com/devnet/devices/flash_platform_tv.html.

More docs are in the works, but in the meantime I thought I’d use this blog to present some of that content.

AIR for TV apps can access the device’s filesystem, but on a “living room” device it is critically important that an app cannot access the device’s system files or the files of other applications installed on the device. Users of TVs and associated devices do not expect or tolerate any device failures — they are watching TV, after all.

Therefore, an AIR for TV application has a limited view of the device’s filesystem. Using ActionScript 3.0, your app can access only the following directories (and their subdirectories). But realize that these names are not the actual directory names on the device. This extra layer protects AIR for TV  applications from maliciously or inadvertently accessing local files that do not belong to them.

  • /app/ is the read-only application directory for the running AIR application.
  • /app-storage/ is the read-write application storage directory for the running AIR application.
  • /home/ is the read-write user directory.
  • /tmp/ is the read-write temporary directory for the running AIR application.
  • /volumes/ is the read-only directory containing zero or more read-write subdirectories that represent mounted volumes.

If an app tries to access any other directory, the runtime throws an exception that the ActionScript code can catch.

As with AIR applications targeting other devices, it’s a best practice to use the following File class properties rather than a directory name:

  • File.applicationDirectory maps to the application’s application-specific directory.  The File.nativePath value of File.applicationDirectory  is /app/ in AIR for TV.
  • File.applicationStorageDirectory maps to an application-specific directory within a user-specific directory.  Its File.nativePath value is /app-storage/ in AIR for TV.
  • File.desktopDirectory maps to an application-specific directory within a user-specific directory.  Its File.nativePath value is /home/ in AIR for TV.
  • File.userDirectory maps to an application-specific directory within a user-specific directory. Its File.nativePath value is /home/ in AIR for TV.
  • File.documentsDirectory maps to an application-specific directory within a user-specific directory. Its File.nativePath value is /home/ in AIR for TV.

Note that File.desktopDirectory, File.userDirectory, and File.documentsDirectory all map to the same directory, which has the File.nativePath value  /home/.

Also consider the behavior of the following methods on AIR for TV devices:

  • File.createTempDirectory() creates a directory with the File.nativePath value /tmp/. AIR for TV maps /tmp/ to a temporary directory on the device. AIR for TV deletes this directory and its contents when the AIR application exits.
  • File.createTempFile() creates a file in the /tmp/ directory.
  • File.getRootDirectories()returns an array with one File object. The File object’s nativePath property has the value /. This root directory contains the directories app, app-storage, home and tmp.
  • StorageVolumeInfo.storageVolumeInfo.getStorageVolumes() returns a Vector of StorageVolume objects. Each StorageVolume object’s rootDirectory property is a File object. The File object’s nativePath value begins with /volumes/. All applications and users have access to the /volumes/ directory.

AIR for TV apps documentation available

If you are developing AIR applications for Adobe AIR for TV, or want to be, check out this Adobe Developer Connection page:  Flash Platform for TV.  You’ll find FAQs, tutorials, demos, and documentation to get you going.

A few documentation highlights include:

The StageVideo class

AIR for TV devices use hardware accelerators to decode and present video, which provide the end-user a great viewing experience while off-loading the device’s CPU.  To take advantage of this video hardware, use the StageVideo ActionScript class instead of the Video class in your application. Read more about the StageVideo class in:

AIR for TV profile support

A device profile defines the set of APIs and capabilities typically supported on a particular class of device.  Your AIR for TV applications will use either the tv or extendedTV profile.  To get an overview of what’s supported in these profiles, see Building Adobe AIR Applications — Device profiles.

Packaging your AIR for TV application

For information about how to package your AIR for TV app, see Developing AIR applications for television devices.

AIR for TV sessions at MAX

You’ve written AIR apps for desktops and mobile devices, and now you can write them for TV, too.

AIR for TV product manager Aditya Bansod has posted a blog entry explaining what you can learn at MAX about AIR for TV.

The most fun session may be the hands-on lab in which you learn to actually develop an AIR application for TV.

Check out Aditya’s post at:

http://blogs.adobe.com/air/2010/09/air-for-tv-sessions-at-max.html