Packagecom.adobe.cc
Classpublic class SimpleCCDecoder
InheritanceSimpleCCDecoder Inheritance CCDecoderImpl Inheritance Object

SimpleCCDecoder is a starting point for integrating closed captioning with an arbitrary streaming library. It can be adapted to work with NetStream, OSMF, or the streaming library of your choice.

While SimpleCCDecoder is the most flexible of all CCDecoder variants, it also requires the most work from you in order to make proper use of its functionality. If there already exists a different CCDecoder variant designed specifically for your streaming library, you are highly encouraged to select that variant over SimpleCCDecoder.

Using SimpleCCDecoder

Enabling closed captioning in your application consists of the following steps:

Prepare your assets

In order to take advantage of SimpleCCDecoder, your assets must be packaged to encapsulate closed captioning data in the onCaptionInfo message. For more information on this area, please consult your packager or encoder vendor.

Initialize the decoder

Initializing the SimpleCCDecoder typically consists of a few steps, as illustrated in the following code:

	 
	     var parent:DisplayObjectContainer = ...;
	     var ccDecoder:SimpleCCDecoder;
	 
	     // create a new instance
	     ccDecoder = new SimpleCCDecoder();
	 
	     parent.addChild(ccDecoder.displayObject);
	 
	     // enable the instance
	     ccDecoder.enabled = true;
	 
	     // optionally select a type and service
	     ccDecoder.type = CCType.CEA708;
	     ccDecoder.service = CEA708Service.CC1;
	 
	 

You should have 1 instance of SimpleCCDecoder per video pane.

A key step in initialization is to properly add SimpleCCDecoder.displayObject to your display list. SimpleCCDecoder.displayObject is the pane on which contain the captions will be rendered. It is intended to be an overlay on top of your video object, and should be added to your display list in such a way that it will be in front of the video object. Typically the SimpleCCDecoder.displayObject and the video object will be the siblings within a common parent DisplayObjectContainer.

Update the video bounds

In order to properly size the caption overlay, you must notify the SimpleCCDecoder of the size of both the original video as well as the video as displayed on screen.

SimpleCCDecoder.videoBounds controls the bounds of the overlay. It must be set to the bounds of the video and updated any time the size of the video on screen will change.

Passing onCaptionInfo to the decoder

A required step in properly using SimpleCCDecoder is to pass onCaptionInfo callbacks to the SimpleCCDecoder.

During packaging, your assets should have onCaptionInfo data messages embedded in stream. Whenever these callbacks arrive for your stream, you must call SimpleCCDecoder.onCaptionInfo to pass captioning information to the decoder.

SimpleCCDecoder.onCaptionInfo(o::void accepts a single object argument. The argument is expected to be an Object with a type and data attributes that follow the onCaptionInfo specification.

Resetting the decoder as needed

To ensure proper behavior, you must call SimpleCCDecoder.reset() whenever a number of situations occur:

SimpleCCDecoder.reset():void will reset the internal 608 decoder. It is analagous to a channel change in the television world.

Allow customization of other closed captioning attributes

SimpleCCDecoder contains a number of properties that should be exposed via user interface controls. Most of these properties enable overriding font and color attributes and are required under FCC guidelines. You are responsible for adding UI controls to expose these properties, as well adding the necessary code to save and restore settings between sessions.



Public Properties
 PropertyDefined By
 InheritedbackgroundColor : int
Background color override to apply to rendered text.
CCDecoderImpl
 InheritedbackgroundOpacity : Number
Background opacity override to apply to rendered text.
CCDecoderImpl
 InheriteddefaultFont : String
The default font to use when no font override is specified.
CCDecoderImpl
  displayObject : DisplayObject
[read-only] The DisplayObject that will contain the rendered captions.
SimpleCCDecoder
 InheritededgeColor : int
Edge color override to apply to rendered text.
CCDecoderImpl
 InheritededgeType : String
Edge type override to apply to rendered text.
CCDecoderImpl
 Inheritedenabled : Boolean
Whether caption data decoding and rendering is enabled or disabled.
CCDecoderImpl
 InheritedenableRollUpAnimations : Boolean
Indicates whether rollup animations should be enabled (true), or not (false).
CCDecoderImpl
 Inheritedfont : String
Font override to apply to rendered text.
CCDecoderImpl
 InheritedfontSize : Number
Font size override to apply to rendered text.
CCDecoderImpl
 InheritedsafeAreaHeightPercent : Number
Override that can be used to resize the safe zone vertical margin.
CCDecoderImpl
 Inheritedservice : String
The caption "service" to decode and render.
CCDecoderImpl
 InheritedtextColor : int
Text color override to apply to rendered text.
CCDecoderImpl
 InheritedtextOpacity : Number
Text opacity override to apply to rendered text.
CCDecoderImpl
 Inheritedtype : String
The active type of closed captioning data to decode and render.
CCDecoderImpl
  videoBounds : Rectangle
The bounds of the overlay.
SimpleCCDecoder
Public Methods
 MethodDefined By
  
Constructs a new SimpleCCDecoder.
SimpleCCDecoder
 Inherited
isServiceActive(service:String):Boolean
Checks if the provided service is active or not.
CCDecoderImpl
  
onCaptionInfo(o:*):void
Processes an onCaptionInfo message.
SimpleCCDecoder
 Inherited
reset():void
Resets the internal decoder and renderer.
CCDecoderImpl
Protected Methods
 MethodDefined By
 Inherited
activateService(activeService:String):void
Called when a new CC service becomes active.
CCDecoderImpl
 Inherited
CCDecoderImpl
Property Detail
displayObjectproperty
displayObject:DisplayObject  [read-only]

The DisplayObject that will contain the rendered captions. It should be added to your display list so that it will may function as an overlay on top of your video object.


Implementation
    public function get displayObject():DisplayObject
videoBoundsproperty 
videoBounds:Rectangle

The bounds of the overlay.


Implementation
    public function get videoBounds():Rectangle
    public function set videoBounds(value:Rectangle):void
Constructor Detail
SimpleCCDecoder()Constructor
public function SimpleCCDecoder()

Constructs a new SimpleCCDecoder.

Method Detail
onCaptionInfo()method
public function onCaptionInfo(o:*):void

Processes an onCaptionInfo message.

Parameters

o:* — An Object with a type and data attributes that follow the onCaptionInfo specification.