Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / Adobe Media Server Developer Center /

Creating a simple OSMF video player for AIR for TV using Flash Builder

by Sarge Sargent

Sarge Sargent
  • Sargeway.com

Content

  • Configuring the development environment
  • Creating a simple OSMF Player
  • Where to go from here

Created

16 December 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash BuilderFlash Media ServerOSMFstreamingTVvideo
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

To get the most out of this article, you should have a basic familiarity with building RIAs using Flash Builder.

 

Additional required other products

Flex 3.6 SDK

AIR 2.5 SDK

OSMF 1.6

User level

Intermediate

Required products

  • Flash Builder 4.5 for PHP Premium (Download trial)

In this article, you'll learn how to create a simple video player that streams Adobe HTTP Dynamic Streaming (HDS) video to Internet-connected televisions, set-top boxes, and other devices. Playing video content on devices requires the AIR for TV (A4TV) 2.5.1 or later runtime. This article describes how to configure Adobe Flash Builder to develop and compile a simple player for A4TV using the Open Source Media Framework (OSMF).

The A4TV runtime requires developers use the proper AIR namespace in their application descriptor file. OSMF facilitates player development for consuming HDS content that cannot be consumed by the popular FLVPlayback or VideoDisplay components. The sample project described in this article uses the following:

  • AIR 2.5 SDK
  • Flex 3.6 SDK
  • OSMF MediaPlayerSprite class

Configuring the development environment

For the purposes of this article, you'll use the Flash Builder 4.5 development environment. If you prefer to use Adobe Flash Professional, see my companion article, Creating a simple OSMF video player for AIR for TV using Flash Professional.

Follow these steps to set up your environment:

  1. Download and install Flash Builder 4.5 (or later).
  2. Install Flash Builder to the desired location on your machine. Your install directory is known as $FlashBuilderRoot.

Flash Builder 4.5 uses the Flex 4.5 SDK by default. The minimum namespace requirement for AIR applications by the Flex 4.5 SDK is AIR 2.6. Since A4TV 2.5.1 requires the AIR 2.5 namespace to run properly, you must use the Flex 3.6 SDK—which has a minimum requirement of AIR 1.5 namespace. Then it is necessary to overlay the AIR 2.5 SDK on the Flex 3.6 SDK to ensure the proper functionality for A4TV 2.5.1 is included when the project is compiled.

Follow these steps to set up AIR 2.5 SDK on the Flex 3.6 SDK:

  1. Download and install the Flex 3.6 SDK. Unzip the package to $FlashBuilderRoot\sdks (or save it to the desired directory).
  2. Download the AIR 2.5 SDK. Overlay it onto the Flex 3.6 SDK by opening the AIR 2.5 SDK ZIP file.
  3. Copy each file from the AIR 2.5 SDK into the corresponding directory within the Flex 3.6 SDK you installed in Step 1.

Note: If you are working on a Mac, be advised that copying a directory over another with the same filename will replace the original directory. Take care to copy only the individual files from the AIR 2.5 SDK into the corresponding directories in the Flex 3.6 SDK to ensure that you do not overwrite the directories.

The AIR 2.5 runtime adds Stage Video support for AIR applications. OSMF build 1.6 automatically enables Stage Video whenever it is available for performance improvements using hardware rendering and decoding of H.264 video. The Flex 3.6 SDK does not support OSMF, so it is necessary to import the OSMF 1.6 SWC file. Follow these steps:

  1. Download the latest OSMF 1.6 (or later) build.
  2. Access the OSMF 1.6 Downloads page and download the OSMF.swc file.

Next, configure your project to use the Flex 3.6 SDK and OSMF 1.6 SWC file:

  1. Launch Flash Builder.
  2. Create a new ActionScript Project by choosing File > New > ActionScript Project.
  3. Enter a project name, tvPlayer, and choose the location to save the project.
  4. Choose Desktop as the Application type.
  5. In the Flex SDK version section, click the Configure Flex SDKs link to open the Preferences dialog box.
  6. Click the Add button and then click the Browse button and navigate to select the newly configured Flex 3.6 SDK. Select the folder and then click OK.
  7. If desired, modify the Flex SDK name and click OK to return to the New ActionScript Project properties dialog box.
  8. Click the Use a specific SDK option and then use the menu to select the Flex 3.6 SDK.
  9. Click the Next button. In the Library path tab, click the Add SWC button.
  10. In the Add SWC dialog box that appears, click the Browse button and navigate to select the OSMF.swc file you downloaded previously. Select the OSMF.swc file and click OK. Then click OK again to close the Add SWC dialog box.
  11. Click Finish to close the New ActionScript Project dialog box.

Now set the compiler directive to require Adobe Flash Player 10.2:

  1. Open the tvPlayer project properties by right-clicking the project name in the Package Explorer and selecting Properties.
  2. Select the ActionScript Compiler category in the Properties dialog box.
  3. Add the following line to the Additional compiler arguments field:
-target-player=10.1

Next, set the application profile to TV in the launch configuration:

  1. In the properties dialog box, select the Run/Debug Settings category.
  2. Select the tvPlayer project, then click Edit to open the Edit Configuration dialog box.
  3. Enter tv in the Profile options, click OK to close the Edit Configuration dialog box, and then click OK again to close the Properties dialog box.

At this point, you've finished setting up the development environment. In the next section, you'll learn how to create the OSMF video player.

Creating a simple OSMF Player

To build this sample project, you'll use the OSMF MediaPlayerSprite (MPS) class. MPS is a wrapper class that provides access to the core functionality of the MediaPlayer, MediaContainer, and MediaFactory classes. The code calls for the URL to a manifest file (.f4m) in order to play HDS content; however, you can also use URLs for progressive download or RTMP streaming from Flash Media Server (FMS).

Follow these steps to create the video player:

  1. Open the tvPlayer.as file in your Flash Builder project.
  2. Place your cursor after the opening curly brace for the tvPlayer class (near line 6) and press the Enter key.
  3. While your cursor is at that location, enter the following code to declare the following variables:
private var tvURL:URLResource = new URLResource($url_to_HDS_manifest.f4m); private var player:MediaPlayerSprite = null;

Note: Replace the $url_to_HDS_manifest.f4m above with the full path to your manifest file, e.g. http://mediapm.edgesuite.net/osmf/content/test/manifest-files/dynamic_Streaming.f4m.

  1. Inside the tvPlayer constructor (near line 16), add the following code:
addEventListener(Event.ADDED_TO_STAGE, init);
  1. Add two new lines after the closing curly brace for the tvPlayer constructor and create an init function:
private function init(event:Event):void { }
  1. Add the following lines of code to the init function body:
stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.quality = StageQuality.HIGH; player = new MediaPlayerSprite(); player.resource = tvURL; player.mediaPlayer.autoPlay = true; var layout:LayoutMetadata = new LayoutMetadata(); layout.scaleMode = ScaleMode.LETTERBOX; layout.height = Capabilities.screenResolutionY; layout.width = Capabilities.screenResolutionX; player.media.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout); addChild(player);
  1. Save tvPlayer.as and test the project.

After making these changes, the final version of the code should look like this:

package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import org.osmf.layout.LayoutMetadata; import org.osmf.layout.ScaleMode; import flash.system.Capabilities; import org.osmf.media.MediaPlayerSprite; import org.osmf.media.URLResource; public class tvPlayer extends Sprite { private var tvURL:URLResource = new URLResource("http://mediapm.edgesuite.net/osmf/content/test/manifest-files/dynamic_Streaming.f4m"); private var player:MediaPlayerSprite = null; public function tvPlayer() { addEventListener(Event.ADDED_TO_STAGE, init); } public function init(event:Event):void { stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; stage.quality = StageQuality.HIGH; player = new MediaPlayerSprite(); player.resource = tvURL; player.mediaPlayer.autoPlay = true; var layout:LayoutMetadata = new LayoutMetadata(); layout.scaleMode = ScaleMode.LETTERBOX; layout.height = Capabilities.screenResolutionY; layout.width = Capabilities.screenResolutionX; player.media.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout); addChild(player); } } }

Where to go from here

After completing the steps provided in this article, you should have successfully created a simple, full-screen, skinless, Stage Video–enabled video player for AIR for TV devices using the OSMF MediaPlayerSprite class in Flash Builder 4.5.

If you'd like to research further, experiment with this sample project by extending this code to add functionality. You can also skin the video player and deploy it on AIR for TV–enabled devices.

To learn more about working with OSMF, see the following resources:

  • Open source media framework developer's guide (PDF)
  • Open source media framework site
  • Open source media framework blog
  • Open source media framework wiki
  • Mastering OSMF tutorial series
  • AIR for TV questions

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Encoding live video to H.264/AVC with Flash Player 11
  • Beginner's guide to streaming audio through Flash Media Server 3.5
  • Beginner's guide to dynamic streaming with Flash Media Server 3.5
  • Beginner's guide to using ActionScript 3.0 with Flash Media Server 3.5
  • Streaming AAC/MP3 files with Flash Media Server 3
  • Beginner's guide to installing Flash Media Server 3.5
  • Beginner's guide to streaming live video with Flash Media Server 3.5
  • Beginner's guide to streaming video with Flash Media Server 3.5
  • Protecting online video distribution with Adobe Flash media technology
  • Live dynamic streaming and DVR for non-developers

Tutorials & Samples

Tutorials

  • Implementing late-binding audio with Adobe Media Server for HTTP Dynamic Streaming and HTTP Live Streaming
  • Troubleshooting hang/crash issues in Adobe Media Server
  • Attaching alternate audio tracks using OSMF

Samples

  • Best practices for real-time collaboration using Flash Media Server
  • Understanding live DVR – Part 2: Using DVRCast with Flash Media Live Encoder 3
  • Understanding live DVR – Part 1: Implementing a live DVR player

Flash Media Server Forum

More
05/22/2013 AMS 5 VOD streaming to Android
05/22/2013 Using UNC path from Client in VOD application
05/21/2013 f4mconfig tool - cant run it
05/21/2013 Recorded Webcam to IOS Device

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement