MediaDisplay

Kind of class:class
Inherits from:UIComponent < UIObject < MovieClip
Implements:
Classpath:mx.controls.MediaDisplay
File last modified:Tuesday, 18 December 2007, 15:44:37

Summary


Constructor
Class properties
Instance properties
Class methods
Class methods inherited from UIObject
Instance methods
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)

version

static version:String = "2.0.2.126"
(read)

Instance properties

_aspectRatio

private _aspectRatio:Boolean
(read)

True to respect the aspect ratio; false to ignore it. Only
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.

_priorTime

private _priorTime:Number = 0
(read)

The playhead time at the prior sample. Used to determine whether to
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.

_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.

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.
            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.
              Component metadata:
                Inspectable
                defaultValue:
                30

                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.
                Component metadata:
                  Inspectable

                  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.
                  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.

                    mediaType

                    mediaType:String
                    (read,write)

                    Set the media type. This should only be called during configuration.
                    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.

                      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
                            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.
                                  aName :
                                  The name of the CuePoint to add.
                                  #
                                  aTime :
                                  The time of 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.

                                  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.

                                  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.

                                  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.

                                  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.
                                  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.

                                  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.

                                  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

                                  size the object
                                  #
                                  Parameters:
                                  w :
                                  width of the object
                                  #
                                  h :
                                  height of the object
                                  #
                                  noEvent:
                                  if true, doesn't broadcast "resize" event
                                  #

                                  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.