MediaDisplay
| Kind of class: | class |
|---|---|
| Inherits from: | UIComponent < UIObject |
| Implements: |
|
| Classpath: | mx.controls.MediaDisplay |
| File last modified: | Wednesday, 27 December 2006, 23:14:24 |
Summary
Constructor
Instance properties
- className : String
- clipParameters : Object
- fps : Number
- The frames per second is only used for video, and is only used in
- initCuePointNames : Array
- An array of cue point names.
- initCuePointTimes : Array
- An array of cue point times.
- _contentPath : String
- _mediaType : String
- _autoSize : Boolean
- Automatically size the component to fit the media that is loaded?
- _aspectRatio : Boolean
- True to respect the aspect ratio; false to ignore it.
- _autoPlay : Boolean
- Automatically play the media at startup?
- _deadPreview : MovieClip
- _toggleControl : FullScreenToggle
- _playerImpl : IPlayer
- _videoHolder : MovieClip
- Holder object that holds the video to show the FLV.
- _soundHolder : MovieClip
- An empty clip used to control the volume of mp3 audio
- _processor : MovieClip
- Clip used for onEnterFrame processing
- _priorTime : Number
- The playhead time at the prior sample.
- _priorBytesLoaded : Number
- The bytes loaded at the prior sample.
- _cuePoints : Array
- The cue points for this piece of media
- _mostRecentCuePoint
- _scrubbing : Boolean
- Boolean to indicate whether we're scrubbing or not.
- _fireCuePoints : Boolean
- Boolean to control firing of cue points.
- _startingTime : Number
- Start time of playback, used for MP3 stream
- _totalTime : Number
- Total number of seconds, used for video stream
- _started : Boolean
- Has the stream started yet?
- _sendCompleteEvent : Boolean
- Should the poll method send a complete event?
- _fullyLoaded : Boolean
- Is the media completely loaded?
- _enabled : Boolean
- Is the component enabled?
- _playingBeforeDisabled : Boolean
- Was the component playing when it was disabled?
- _pollId : Number
- The interval id for polling
- makeVideoVisible : Boolean
- A flag that tells the draw() function to make the video object visible.
- _screenAccommodator : ScreenAccommodator
- The screen accommodator automatically enables and disables the
- videoWidth : Number
- videoHeight : Number
- preferredWidth : Number
- preferredHeight : Number
- autoSize : Boolean
- aspectRatio : Boolean
- autoPlay : Boolean
- Autoplay is strictly an initialization parameter.
- playheadTime : Number
- contentPath : String
- Create a contentPath property.
- volume : Number
- playing : Boolean
- bytesLoaded : Number
- bytesTotal : Number
- mediaType : String
- Set the media type.
- totalTime : Number
- cuePoints : Array
- An array of cue point objects
- mostRecentCuePoint : CuePoint
- Retrieve the most recently fired cue point.
- mostRecentCuePointName : String
- mostRecentCuePointTime : Number
- Retrieve the most recently fired cue point time.
- enabled : Boolean
Instance properties inherited from UIComponent
Instance methods
- init (Void) : Void
- Initialize the player.
- initializeParameters : Void
- Create default values for absent parameters
- initCuePoints : Void
- Initialize the cue points from the init parameters.
- initMedia (switchType:Boolean) : Void
- Prepare the component for the media and load it.
- draw : Void
- Update the display -- size the video object.
- setVideoDisplaySize (w:Number, h:Number) : Void
- assignPreferredSize : Void
- handlePlayer (player:IPlayer, status:String)
- Handle events broadcast by the player implementation.
- toString : String
- load : Void
- Load the media without playing it.
- play (startingPoint:Number) : Void
- Play the media starting at the specified starting point.
- pause : Void
- Stop playback of the media without moving the playhead.
- stop : Void
- Stop playback of the media and reset the playhead to zero.
- setMedia (aUrl:String, aType:String)
- Set both the content path and the media type together.
- deduceMediaType (aUrl:String) : String
- releaseVideo : Void
- Completely release the video from the display.
- isLivePreview : Boolean
- isFLV : Boolean
- Convenience function for internal use only
- isMP3 : Boolean
- Convenience function for internal use only
- getCuePoints : Array
- setCuePoints (cp:Array) : Void
- An array of cue point objects
- getCuePoint (pointName:String) : CuePoint
- addCuePoint (aName:String, aTime:Number) : Void
- Add the given cue point.
- addCuePointObject (aCuePoint:CuePoint) : Void
- Add the given cue point.
- removeCuePoint (aCuePoint:CuePoint) : Void
- Remove the given cue point.
- removeAllCuePoints : Void
- Remove all the CuePoints.
- handleEvent (ev:Object) : Void
- Listen to events from the controller.
- handlePlayEvent (ev:Object) : Void
- Handle a click on the play button
- handleStopEvent (ev:Object) : Void
- Handle a click on the stop button
- handlePauseEvent (ev:Object) : Void
- Handle a click on the pause button
- handleRewindEvent (ev:Object) : Void
- Handle a click on the rewind button
- handleFastForwardEvent (ev:Object) : Void
- Handle a click on the fast forward button
- handlePlayheadChangeEvent (ev:Object) : Void
- Handle a new playhead position event
- handleVolumeEvent (ev:Object) : Void
- Handle a volume event
- handleScrubbingEvent (ev:Object) : Void
- Handle a scrubbing event
- handleUnrecognizedEvent (ev:Object) : Void
- Handle an unrecognized event
- getCuePointIndex (pointName:String) : Number
- poll (first:Boolean) : Void
- Monitor the current status of the component.
- isRtmp (mediaUrl:String) : Boolean
- associateController (c:MediaController) : Void
- Associated this display with a controller.
- setSize (w:Number, h:Number, noEvent:Boolean) : Void
Event handlers
- onUnload : Void
- Make sure media playing stops when we unload the clip.
Event handlers inherited from UIComponent
Constructor
MediaDisplay
function MediaDisplay (
)
Constructor
Class properties
symbolName
static symbolName:String = "MediaDisplay"
(read)
symbolOwner
static symbolOwner:Object = mx.controls.MediaDisplay
(read)
Instance properties
_aspectRatio
private _aspectRatio:Boolean
(read)
True to respect the aspect ratio; false to ignore it. Only
applies if autoSize = false.
applies if autoSize = false.
_autoPlay
private _autoPlay:Boolean
(read)
Automatically play the media at startup?
_autoSize
private _autoSize:Boolean
(read)
Automatically size the component to fit the media that is loaded?
_contentPath
private _contentPath:String
(read)
_cuePoints
private _cuePoints:Array
(read)
The cue points for this piece of media
_deadPreview
private _deadPreview:MovieClip
(read)
_enabled
private _enabled:Boolean = true
(read)
Is the component enabled?
_fireCuePoints
private _fireCuePoints:Boolean = true
(read)
Boolean to control firing of cue points. We don't want to fire them on rewind, for example.
_fullyLoaded
private _fullyLoaded:Boolean
(read)
Is the media completely loaded?
_mediaType
private _mediaType:String
(read)
_mostRecentCuePoint
private _mostRecentCuePoint
(read)
The most recently fired cue point
_playerImpl
private _playerImpl:IPlayer
(read)
_playingBeforeDisabled
private _playingBeforeDisabled:Boolean
(read)
Was the component playing when it was disabled?
_pollId
private _pollId:Number
(read)
The interval id for polling
_priorBytesLoaded
private _priorBytesLoaded:Number = 0
(read)
The bytes loaded at the prior sample. Used to determine whether to
broadcast a progress event.
broadcast a progress event.
_priorTime
private _priorTime:Number = 0
(read)
The playhead time at the prior sample. Used to determine whether to
broadcast a change event.
broadcast a change event.
_processor
private _processor:MovieClip
(read)
Clip used for onEnterFrame processing
_screenAccommodator
private _screenAccommodator:ScreenAccommodator
(read)
The screen accommodator automatically enables and disables the
component inside a screen.
component inside a screen.
_scrubbing
private _scrubbing:Boolean = false
(read)
Boolean to indicate whether we're scrubbing or not. If scrubbing, fire the cuepoints even if _fireCuePoints is false.
_sendCompleteEvent
private _sendCompleteEvent:Boolean
(read)
Should the poll method send a complete event?
_soundHolder
private _soundHolder:MovieClip
(read)
An empty clip used to control the volume of mp3 audio
_started
private _started:Boolean
(read)
Has the stream started yet?
_startingTime
private _startingTime:Number
(read)
Start time of playback, used for MP3 stream
_toggleControl
private _toggleControl:FullScreenToggle
(read)
_totalTime
private _totalTime:Number
(read)
Total number of seconds, used for video stream
_videoHolder
private _videoHolder:MovieClip
(read)
Holder object that holds the video to show the FLV.
Put the video in a holder so that the volume can be controlled
by attaching a sound object to the holder.
Put the video in a holder so that the volume can be controlled
by attaching a sound object to the holder.
aspectRatio
aspectRatio:Boolean
(read,write)
Component metadata:
| Inspectable | defaultValue: true |
|---|
autoPlay
autoPlay:Boolean
(read,write)
Autoplay is strictly an initialization parameter.
Component metadata:
| Inspectable | defaultValue: true |
|---|
autoSize
autoSize:Boolean
(read,write)
Component metadata:
| Inspectable | defaultValue: true |
|---|
bytesLoaded
bytesLoaded:Number
(read)
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent |
bytesTotal
bytesTotal:Number
(read)
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent |
className
className:String = "MediaDisplay"
(read)
clipParameters
clipParameters:Object = {}
(read)
contentPath
contentPath:String
(read,write)
Create a contentPath property. Set the content path. This should only be called during configuration.
It does not work at runtime.
It does not work at runtime.
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "start" |
| Inspectable | defaultValue: "" |
cuePoints
cuePoints:Array
(read,write)
An array of cue point objects
Returns:
- An array of CuePoint objects. All the CuePoints associated
with this object.
enabled
enabled:Boolean
(read,write)
fps
fps:Number
(read)
The frames per second is only used for video, and is only used in
the configuration UI. The config UI uses it to calculate
milliseconds based on frame number.
the configuration UI. The config UI uses it to calculate
milliseconds based on frame number.
Component metadata:
| Inspectable | "danger", 1, maybe true, |
|---|
initCuePointNames
initCuePointNames:Array
(read)
An array of cue point names. One for each cue point.
Each entry is a string.
This is only used at startup to initialize the cue point array.
Each entry is a string.
This is only used at startup to initialize the cue point array.
Component metadata:
| Inspectable | defaultValue: "auto" enumeration: "auto,on,off", |
|---|
initCuePointTimes
initCuePointTimes:Array
(read)
An array of cue point times. One for each cue point.
There must be the same number as there are names.
Each element is the number of seconds, with decimals allowed.
This is only used at startup to initialize the cue point array.
There must be the same number as there are names.
Each element is the number of seconds, with decimals allowed.
This is only used at startup to initialize the cue point array.
Component metadata:
| Inspectable |
|---|
makeVideoVisible
makeVideoVisible:Boolean = false
(read)
A flag that tells the draw() function to make the video object visible.
This is public because the MediaPlayback class needs to be able to
set it.
This is public because the MediaPlayback class needs to be able to
set it.
mediaType
mediaType:String
(read,write)
Set the media type. This should only be called during configuration.
It does not work at runtime.
It does not work at runtime.
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "start" |
| Inspectable | defaultValue: "FLV" enumeration: "MP3,FLV" |
mostRecentCuePoint
mostRecentCuePoint:CuePoint
(read)
Retrieve the most recently fired cue point.
Unbindable since binding cannot handle structures.
Unbindable since binding cannot handle structures.
mostRecentCuePointName
mostRecentCuePointName:String
(read)
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "cuePoint" |
mostRecentCuePointTime
mostRecentCuePointTime:Number
(read)
Retrieve the most recently fired cue point time.
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "cuePoint" |
playheadTime
playheadTime:Number
(read,write)
Returns:
- The playhead position, measued in seconds since the start.
Component metadata:
| Bindable | "datatype" "readonly" "writeonly",type |
|---|---|
| ChangeEvent | "change" |
playing
playing:Boolean
(read)
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "change" |
preferredHeight
preferredHeight:Number
(read)
Returns:
- The preferred height of the display.
This is the height of the video object.
preferredWidth
preferredWidth:Number
(read)
Returns:
- The preferred width of the display.
This is the width of the video object.
totalTime
totalTime:Number
(read,write)
Returns:
- The total time of the media. For mp3 files, this is a
property of the Sound object. For video, it is be a property
that is manually set by the author.
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "start" |
| Inspectable | defaultValue: 0 |
videoHeight
videoHeight:Number
(read)
Returns:
- The actual height of the display.
videoWidth
videoWidth:Number
(read)
Returns:
- The actual width of the video display.
volume
volume:Number
(read,write)
Returns:
- The most recent volume setting
Component metadata:
| Bindable | |
|---|---|
| ChangeEvent | "volume" |
Instance methods
addCuePoint
function addCuePoint (
aName:String,
aTime:Number) : Void
Add the given cue point.
Parameters:
aCuePoint:
The CuePoint to add.
addCuePointObject
function addCuePointObject (
aCuePoint:CuePoint) : Void
Add the given cue point.
Parameters:
aCuePoint:
The CuePoint to add.
assignPreferredSize
function assignPreferredSize (
) : Void
associateController
function associateController (
c:MediaController) : Void
Associated this display with a controller. Set up the event listeners
between the two.
between the two.
deduceMediaType
private function deduceMediaType (
aUrl:String) : String
draw
function draw (
) : Void
Update the display -- size the video object. Don't do anything
for mp3 media.
for mp3 media.
getCuePoint
function getCuePoint (
pointName:String) : CuePoint
Parameters:
pointName:
The name of the cue point to find.
Returns:
- The CuePoint associated with this object that has the given
name.
getCuePointIndex
private function getCuePointIndex (
pointName:String) : Number
Returns:
- The index of the cue point with given name, or -1 if not found.
getCuePoints
function getCuePoints (
) : Array
Returns:
- An array of CuePoint objects. All the CuePoints associated
with this object.
handleEvent
function handleEvent (
ev:Object) : Void
Listen to events from the controller. The following events are
actually propogated: click, playheadChange, volume.
The others included below were available during development
but are not now.
actually propogated: click, playheadChange, volume.
The others included below were available during development
but are not now.
handleFastForwardEvent
private function handleFastForwardEvent (
ev:Object) : Void
Handle a click on the fast forward button
handlePauseEvent
private function handlePauseEvent (
ev:Object) : Void
Handle a click on the pause button
handlePlayer
function handlePlayer (
player:IPlayer,
status:String)
Handle events broadcast by the player implementation.
handlePlayEvent
private function handlePlayEvent (
ev:Object) : Void
Handle a click on the play button
handlePlayheadChangeEvent
private function handlePlayheadChangeEvent (
ev:Object) : Void
Handle a new playhead position event
handleRewindEvent
private function handleRewindEvent (
ev:Object) : Void
Handle a click on the rewind button
handleScrubbingEvent
private function handleScrubbingEvent (
ev:Object) : Void
Handle a scrubbing event
handleStopEvent
private function handleStopEvent (
ev:Object) : Void
Handle a click on the stop button
handleUnrecognizedEvent
private function handleUnrecognizedEvent (
ev:Object) : Void
Handle an unrecognized event
handleVolumeEvent
private function handleVolumeEvent (
ev:Object) : Void
Handle a volume event
init
function init (
Void) : Void
Initialize the player.
initCuePoints
private function initCuePoints (
) : Void
Initialize the cue points from the init parameters.
The data from the initCuePointNames and initCuePointTimes arrays
will be consolidated into the single _cuePoints array.
The data from the initCuePointNames and initCuePointTimes arrays
will be consolidated into the single _cuePoints array.
initializeParameters
private function initializeParameters (
) : Void
Create default values for absent parameters
initMedia
function initMedia (
switchType:Boolean) : Void
Prepare the component for the media and load it.
Parameters:
switchType:
Switch to a new media type. OPTIONAL
isFLV
private function isFLV (
) : Boolean
Convenience function for internal use only
isLivePreview
private function isLivePreview (
) : Boolean
Returns:
- True if we are in live preview; false if not.
isMP3
private function isMP3 (
) : Boolean
Convenience function for internal use only
isRtmp
function isRtmp (
mediaUrl:String) : Boolean
load
function load (
) : Void
Load the media without playing it.
pause
function pause (
) : Void
Stop playback of the media without moving the playhead.
play
function play (
startingPoint:Number) : Void
Play the media starting at the specified starting point. If the media
hasn't yet been loaded, load it.
hasn't yet been loaded, load it.
Parameters:
startingPoint:
The number of seconds into the media to start at.
This is an optional parameter. If omitted, playing will occur
at the current playhead position.
This is an optional parameter. If omitted, playing will occur
at the current playhead position.
poll
private function poll (
first:Boolean) : Void
Monitor the current status of the component.
Parameters:
first:
True if this is the first time poll is being called.
releaseVideo
private function releaseVideo (
) : Void
Completely release the video from the display. This is trickier
than it might seem. Incompletely releasing the video leads to problems.
If the same FLV is subsequently reloaded and its video or audio
is already attached to the movie, the NetStream.play() call will fail.
than it might seem. Incompletely releasing the video leads to problems.
If the same FLV is subsequently reloaded and its video or audio
is already attached to the movie, the NetStream.play() call will fail.
removeAllCuePoints
function removeAllCuePoints (
) : Void
Remove all the CuePoints.
removeCuePoint
function removeCuePoint (
aCuePoint:CuePoint) : Void
Remove the given cue point.
Parameters:
aCuePoint:
The CuePoint to remove.
setCuePoints
function setCuePoints (
cp:Array) : Void
An array of cue point objects
setMedia
function setMedia (
aUrl:String,
aType:String)
Set both the content path and the media type together.
setSize
function setSize (
w:Number,
h:Number,
noEvent:Boolean) : Void
setVideoDisplaySize
private function setVideoDisplaySize (
w:Number,
h:Number) : Void
Parameters:
w:
The new width of the component
h:
The new height of the component
stop
function stop (
) : Void
Stop playback of the media and reset the playhead to zero.
toString
function toString (
) : String
Returns:
- A string representation of this object
Event handlers
onUnload
function onUnload (
) : Void
Make sure media playing stops when we unload the clip.