ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
org.osmf.traits 

DynamicStreamTrait  - AS3 OSMF

Packageorg.osmf.traits
Classpublic class DynamicStreamTrait
InheritanceDynamicStreamTrait Inheritance MediaTraitBase Inheritance EventDispatcher Inheritance Object

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

DynamicStreamTrait defines the trait interface for media supporting dynamic stream switching. It can also be used as the base class for a more specific DynamicStreamTrait subclass.

Use the MediaElement.hasTrait(MediaTraitType.DYNAMIC_STREAM) method to query whether a media element has a trait of this type. If hasTrait(MediaTraitType.DYNAMIC_STREAM) returns true, use the MediaElement.getTrait(MediaTraitType.DYNAMIC_STREAM) method to get an object of this type.

Related API Elements



Public Properties
 PropertyDefined By
  autoSwitch : Boolean
Defines whether or not the trait should be in manual or auto-switch mode.
DynamicStreamTrait
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  currentIndex : int
[read-only] The index of the current dynamic stream.
DynamicStreamTrait
  maxAllowedIndex : int
The maximum allowed index.
DynamicStreamTrait
  numDynamicStreams : int
[read-only] The total number of dynamic streams.
DynamicStreamTrait
  switching : Boolean
[read-only] Indicates whether or not a switch is currently in progress.
DynamicStreamTrait
 InheritedtraitType : String
[read-only] The MediaTraitType for this trait.
MediaTraitBase
Public Methods
 MethodDefined By
  
DynamicStreamTrait(autoSwitch:Boolean = true, currentIndex:int = 0, numDynamicStreams:int = 1)
Constructor.
DynamicStreamTrait
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Disposes of any resources used by this trait.
MediaTraitBase
  
Returns the associated bitrate, in kilobits per second, for the specified index.
DynamicStreamTrait
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
  
Switch to a specific index.
DynamicStreamTrait
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Protected Methods
 MethodDefined By
  
Called just after the autoSwitch property has changed.
DynamicStreamTrait
  
Called immediately before the autoSwitch property is changed.
DynamicStreamTrait
  
Called just after the maxAllowedIndex property has changed.
DynamicStreamTrait
  
Called immediately before the maxAllowedIndex property is changed.
DynamicStreamTrait
  
Invoking this setter will result in the trait's currentIndex property changing.
DynamicStreamTrait
  
Invoking this setter will result in the trait's numDynamicStreams property changing.
DynamicStreamTrait
  
setSwitching(newSwitching:Boolean, index:int):void
Must be called by the implementing media on completing a switch.
DynamicStreamTrait
  
Called just after the switching property has changed.
DynamicStreamTrait
  
switchingChangeStart(newSwitching:Boolean, index:int):void
Called immediately before the switching property is changed.
DynamicStreamTrait
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
  Dispatched when the autoSwitch property changed.DynamicStreamTrait
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when the number of dynamic streams has changed.DynamicStreamTrait
  Dispatched when a stream switch is requested, completed, or failed.DynamicStreamTrait
Property Detail

autoSwitch

property
autoSwitch:Boolean

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Defines whether or not the trait should be in manual or auto-switch mode. If in manual mode the switchTo method can be used to manually switch to a specific stream.



Implementation
    public function get autoSwitch():Boolean
    public function set autoSwitch(value:Boolean):void

currentIndex

property 
currentIndex:int  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The index of the current dynamic stream. Uses a zero-based index.



Implementation
    public function get currentIndex():int

maxAllowedIndex

property 
maxAllowedIndex:int

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The maximum allowed index. This can be set at run-time to provide a ceiling for the switching profile, for example, to keep from switching up to a higher quality stream when the current video is too small to handle a higher quality stream. The default is the highest stream index.



Implementation
    public function get maxAllowedIndex():int
    public function set maxAllowedIndex(value:int):void

Throws
RangeError — If the specified index is less than zero or greater than the total number of dynamic streams.

numDynamicStreams

property 
numDynamicStreams:int  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The total number of dynamic streams.



Implementation
    public function get numDynamicStreams():int

switching

property 
switching:Boolean  [read-only]

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Indicates whether or not a switch is currently in progress. This property will return true while a switch has been requested and the switch has not yet been acknowledged and no switch failure has occurred. Once the switch request has been acknowledged or a failure occurs, the property will return false.



Implementation
    public function get switching():Boolean
Constructor Detail

DynamicStreamTrait

()Constructor
public function DynamicStreamTrait(autoSwitch:Boolean = true, currentIndex:int = 0, numDynamicStreams:int = 1)

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Constructor.

Parameters
autoSwitch:Boolean (default = true) — The initial autoSwitch state for the trait. The default is true.
 
currentIndex:int (default = 0) — The initial stream index for the trait. The default is zero.
 
numDynamicStreams:int (default = 1) — The total number of dynamic streams.
Method Detail

autoSwitchChangeEnd

()method
protected function autoSwitchChangeEnd():void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called just after the autoSwitch property has changed. Dispatches the change event.

Subclasses that override should call this method to dispatch the change event.

autoSwitchChangeStart

()method 
protected function autoSwitchChangeStart(value:Boolean):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called immediately before the autoSwitch property is changed.

Subclasses can override this method to communicate the change to the media.

Parameters

value:Boolean — New value for the autoSwitch property.

getBitrateForIndex

()method 
public function getBitrateForIndex(index:int):Number

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Returns the associated bitrate, in kilobits per second, for the specified index.

Parameters

index:int

Returns
Number

Throws
RangeError — If the specified index is less than zero or greater than the highest index available.

maxAllowedIndexChangeEnd

()method 
protected function maxAllowedIndexChangeEnd():void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called just after the maxAllowedIndex property has changed.

maxAllowedIndexChangeStart

()method 
protected function maxAllowedIndexChangeStart(newIndex:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called immediately before the maxAllowedIndex property is changed.

Subclasses can override this method to communicate the change to the media.

Parameters

newIndex:int — New value for the maxAllowedIndex property.

setCurrentIndex

()method 
protected final function setCurrentIndex(value:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Invoking this setter will result in the trait's currentIndex property changing.

Parameters

value:int

setNumDynamicStreams

()method 
protected final function setNumDynamicStreams(value:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Invoking this setter will result in the trait's numDynamicStreams property changing.

Parameters

value:int

setSwitching

()method 
protected final function setSwitching(newSwitching:Boolean, index:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Must be called by the implementing media on completing a switch. Calls the switchingChangeStart() and switchingChangeEnd() methods.

Parameters

newSwitching:Boolean — New switching value for the trait.
 
index:int — The index to which the switch shall (or did) occur.

switchingChangeEnd

()method 
protected function switchingChangeEnd(index:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called just after the switching property has changed. Dispatches the change event.

Subclasses that override should call this method to dispatch the change event.

Parameters

index:int — The index of the switched-to stream.

switchingChangeStart

()method 
protected function switchingChangeStart(newSwitching:Boolean, index:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Called immediately before the switching property is changed.

Subclasses can override this method to communicate the change to the media.

Parameters

newSwitching:Boolean — New value for the switching property.
 
index:int — The index of the stream to switch to.

switchTo

()method 
public function switchTo(index:int):void

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Switch to a specific index. To switch up, use the currentIndex property, such as:

obj.switchTo(obj.currentIndex + 1);

Parameters

index:int

Throws
RangeError — If the specified index is less than zero or greater than maxAllowedIndex. Note: If the media is paused, switching will not take place until after play resumes.
 
IllegalOperationError — If the stream is not in manual switch mode.

Related API Elements

maxAllowedIndex
Event Detail

autoSwitchChange

Event
Event Object Type: org.osmf.events.DynamicStreamEvent
property DynamicStreamEvent.type = org.osmf.events.DynamicStreamEvent.AUTO_SWITCH_CHANGE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when the autoSwitch property changed.

The DynamicStreamEvent.AUTO_SWITCH_CHANGE constant defines the value of the type property of the event object for an autoSwitchChange event.

numDynamicStreamsChange

Event  
Event Object Type: org.osmf.events.DynamicStreamEvent
property DynamicStreamEvent.type = org.osmf.events.DynamicStreamEvent.NUM_DYNAMIC_STREAMS_CHANGE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when the number of dynamic streams has changed.

The DynamicStreamEvent.NUM_DYNAMIC_STREAMS_CHANGE constant defines the value of the type property of the event object for a numDynamicStreamsChange event.

switchingChange

Event  
Event Object Type: org.osmf.events.DynamicStreamEvent
property DynamicStreamEvent.type = org.osmf.events.DynamicStreamEvent.SWITCHING_CHANGE

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Dispatched when a stream switch is requested, completed, or failed.

The DynamicStreamEvent.SWITCHING_CHANGE constant defines the value of the type property of the event object for a switchingChange event.