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 

PlayTrait  - AS3 OSMF

Packageorg.osmf.traits
Classpublic class PlayTrait
InheritancePlayTrait Inheritance MediaTraitBase Inheritance EventDispatcher Inheritance Object

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

PlayTrait defines the trait interface for media whose playback can be started and stopped. It can be used as the base class for a more specific PlayTrait subclass.

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

Related API Elements



Public Properties
 PropertyDefined By
  canPause : Boolean
[read-only] Indicates whether the media can be paused.
PlayTrait
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  playState : String
[read-only] The current playback state, of type PlayState.
PlayTrait
 InheritedtraitType : String
[read-only] The MediaTraitType for this trait.
MediaTraitBase
Public Methods
 MethodDefined By
  
Constructor.
PlayTrait
 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
 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
  
Pauses the media if it is not already paused.
PlayTrait
  
Plays the media if it is not already playing.
PlayTrait
 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
  
Stops the media if it is not already stopped.
PlayTrait
 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 playState property value has changed.
PlayTrait
  
Called immediately before the playState property value is changed.
PlayTrait
  
Sets the canPause property for this PlayTrait.
PlayTrait
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 canPause property has changed.PlayTrait
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
  Dispatched when playback resumes after a live stallPlayTrait
  Dispatched when playback runs out of content for a live stream but the stream is not done.PlayTrait
  Dispatched when the playState of the PlayTrait has changed.PlayTrait
Property Detail

canPause

property
canPause:Boolean  [read-only]

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

Indicates whether the media can be paused. If false, then the pause() method is not supported.



Implementation
    public function get canPause():Boolean

playState

property 
playState:String  [read-only]

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

The current playback state, of type PlayState.



Implementation
    public function get playState():String
Constructor Detail

PlayTrait

()Constructor
public function PlayTrait()

Constructor.

Method Detail

pause

()method
public final function pause():void

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

Pauses the media if it is not already paused.


Throws
IllegalOperationError — If canPause returns false.

play

()method 
public final function play():void

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

Plays the media if it is not already playing.

playStateChangeEnd

()method 
protected function playStateChangeEnd():void

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

Called just after the playState property value has changed. Dispatches the change event.

Subclasses that override should call this method to dispatch the relevant PlayEvent.

playStateChangeStart

()method 
protected function playStateChangeStart(newPlayState:String):void

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

Called immediately before the playState property value is changed.

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

Parameters

newPlayState:String

setCanPause

()method 
protected final function setCanPause(value:Boolean):void

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

Sets the canPause property for this PlayTrait.

Parameters

value:Boolean

stop

()method 
public final function stop():void

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

Stops the media if it is not already stopped.

When media is stopped, then any subsequent call to play should start from the beginning (though this is up to the actual implementation).

Event Detail

canPauseChange

Event
Event Object Type: org.osmf.events.PlayEvent
property PlayEvent.type = org.osmf.events.PlayEvent.CAN_PAUSE_CHANGE

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

Dispatched when the canPause property has changed.

The PlayEvent.CAN_PAUSE_CHANGE constant defines the value of the type property of the event object for a canPauseChange event.

liveResume

Event  
Event Object Type: org.osmf.events.PlayEvent
property PlayEvent.type = org.osmf.events.PlayEvent.LIVE_RESUME

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

Dispatched when playback resumes after a live stall

The PlayEvent.LIVE_RESUME constant defines the value of the type property of the event object for a liveResume event.

Dispatched when playback resumes after a live stall

liveStall

Event  
Event Object Type: org.osmf.events.PlayEvent
property PlayEvent.type = org.osmf.events.PlayEvent.LIVE_STALL

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

Dispatched when playback runs out of content for a live stream but the stream is not done.

The PlayEvent.LIVE_STALL constant defines the value of the type property of the event object for a liveStall event.

Dispatched when playback runs out of content for a live stream but the stream is not done.

playStateChange

Event  
Event Object Type: org.osmf.events.PlayEvent
property PlayEvent.type = org.osmf.events.PlayEvent.PLAY_STATE_CHANGE

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

Dispatched when the playState of the PlayTrait has changed.

The PlayEvent.PLAY_STATE_CHANGE constant defines the value of the type property of the event object for a playStateChange event.