Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders 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
Review and Checkout
Adobe Developer Connection / Flash Media Server Developer Center /

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

by Sarge Sargent

Sarge Sargent
  • Sargeway.com

Content

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

Created

3 January 2012

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Adobe AIR Flash Media Server Flash Professional OSMF streaming TV video

Requirements

Prerequisite knowledge

This article assumes you have prior experience building applications with Flash Professional.

 

Additional required other product:

  • OSMF 1.6

User level

Intermediate

Required products

  • Flash Professional (Download trial)

In this article you'll learn how to create a simple video player for streaming 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 Professional to develop and compile a simple player for A4TV using the Open Source Media Framework (OSMF).

The A4TV runtime requires developers to 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
  • OSMF MediaPlayerSprite class

Configuring the development environment

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

Follow these steps to set up your environment:

  1. Download and install Flash Professional CS5.5.
  2. Install Flash Professional in the desired location on your machine. Your install directory is known as $FlashRoot.
  3. Launch Flash Professional and create a new AIR document.
  4. If the Welcome screen is displayed, select AIR in the Create New section; if the Welcome screen is not displayed, choose File > New to access the New File dialog box.
  5. Select AIR and click OK to close the dialog box.

Flash Professional CS5.5 uses AIR 2.6 by default—which requires the AIR 2.6 namespace. Since A4TV 2.5.1 requires the AIR 2.5 namespace to run properly, you must configure your player to use AIR 2.5. 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. Flash Professional does not provide OSMF classes, so you must import the OSMF 1.6 SWC file into the Library. Follow these steps to configure the project to use AIR 2.5 and the OSMF 1.6 SWC file:

  1. Open the Publish Settings dialog by choosing File > Publish Settings.
  2. In the Publish Settings dialog box, set the Player option to AIR 2.5.
  3. Click the wrench icon next to the Player option to access the AIR Settings dialog box.
  4. In the Profiles section, uncheck all of the check boxes except the one next to TV. Click OK.
  5. Ensure the Script option is set to ActionScript 3.0.
  6. Click the wrench next to the Script option to open the Advanced ActionScript 3.0 Settings dialog box.
  7. In the Library path tab, click the Flash Player icon to open the Browse to SWC file dialog box.
  8. Browse to the location of the OSMF.swc file you downloaded previously.
  9. Select the SWF file and click Open. The OSMF.swc file is listed in the Library tab.
  10. Click OK to close the Advanced ActionScript 3.0 Settings dialog box and then click OK again to close the Publish Settings dialog box.
  11. Choose File > Save to save the Flash project as tvPlayer.fla.

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

We will use the OSMF MediaPlayerSprite (MPS) class. MPS is a wrapper class providing access to the core functionality of the MediaPlayer, MediaContainer, and MediaFactory classes. The code calls for the URL to a manifest file (.f4m) for playing HDS content; however, you can use URLs for progressive download or RTMP streaming from FMS:

  1. With the tvPlayer.fla file open in Flash Professional, create a new layer named Actions and click its first frame.
  2. Open the Actions panel (Window > Actions).
  3. Create the following variables:
var tvURL:URLResource = new URLResource($url_to_HDS_manifest.f4m); 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. Add a new line then make a call to the init function (which is created in next step):
init();
  1. Add two new lines and create the init function signature:
function init():void { }
  1. Add the following lines to 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.

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

import org.osmf.media.MediaPlayerSprite; import org.osmf.media.URLResource; import flash.events.Event; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.StageQuality; import org.osmf.layout.LayoutMetadata; import org.osmf.layout.ScaleMode; import flash.system.Capabilities; var tvURL:URLResource = new URLResource("http://mediapm.edgesuite.net/osmf/content/test/manifest-files/dynamic_Streaming.f4m"); var player:MediaPlayerSprite = null; init(); function init():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; trace("here"); 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 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 Professional CS5.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:

  • Video development with Flash Developer Center
  • Mastering OSMF tutorial series
  • Open source media framework site
  • Open source media framework blog
  • Open source media framework wiki
  • 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

  • Introducing Adobe Flash Media Server 4.5
  • Beginning Flash Media Server 4.5 – Part 5: Streaming with OSMF players
  • Beginning Flash Media Server 4.5 – Part 2: RTMP streaming on-demand video
  • Beginning Flash Media Server 4.5 – Part 4: RTMP streaming audio
  • Beginning Flash Media Server 4.5 – Part 6: Using HTTP Dynamic Streaming
  • Install Flash Media Server 4.5 and verify HTTP streaming to Flash and iOS
  • Beginning Flash Media Server 4.5 – Part 3: RTMP streaming live video
  • Stream on-demand video over HTTP to Flash and iOS
  • Stream on-demand multi-bitrate video over HTTP to Flash and iOS
  • Capture, encode, and stream live video over HTTP to Flash and iOS

Tutorials & Samples

Tutorials

  • OSMF video player for AIR for TV using Flash Professional
  • OSMF video player for AIR for TV using Flash Builder
  • Capture, encode, and stream live video over HTTP to Flash and iOS

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
04/23/2012 FMS Issues
04/23/2012 FMLE 3.2 to FMS 4.5 - Over time the stream delay increases
04/23/2012 Live stream on FMS issues when reaching 1600 concurrent users
04/23/2012 How does main.asc work in signed folder ('live' or 'vod') with FMS4.5?

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

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 © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement