Menu

[r331]: / trunk / framework / OSMF / org / osmf / elements / ParallelElement.as  Maximize  Restore  History

Download this file

196 lines (187 with data), 7.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*****************************************************
*
* Copyright 2009 Adobe Systems Incorporated. All Rights Reserved.
*
*****************************************************
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
*
* The Initial Developer of the Original Code is Adobe Systems Incorporated.
* Portions created by Adobe Systems Incorporated are Copyright (C) 2009 Adobe Systems
* Incorporated. All Rights Reserved.
*
*****************************************************/
package org.osmf.elements
{
import org.osmf.elements.compositeClasses.CompositeMetadata;
import org.osmf.elements.compositeClasses.CompositionMode;
import org.osmf.metadata.Metadata;
import org.osmf.traits.MediaTraitBase;
/**
* ParallelElement is a media composition whose elements are presented
* in parallel (concurrently).
*
* <p>The media elements that make up a ParallelElement are treated as a
* single, unified media element. For example, if a ParallelElement
* encapsulates a image and a piece of audio, the ParallelElement will
* behave as if it's a single MediaElement with the audio characteristics
* of the audio file and the display characteristics of the image file.</p>
*
* <p>Typically, a trait on a ParallelElement is a composite or merged combination
* of that trait on all its children. When a new media element is added as a child
* of the media composition, either its traits or the composite's traits are adjusted
* to make the traits of the media composition and its children consistent.</p>
* <p> As an example of the first case, consider AudioTrait.
* If a client adds a new MediaElement that has its AudioTrait volume at 0.5
* to a ParallelElement that has its AudioTrait volume at 0.3,
* the AudioTrait volume for the child MediaElement is set to 0.3
* to be consistent with ParallelElement's trait.</p>
* <p>As an example of the second case, consider BufferTrait.
* If the added MediaElement has a BufferTrait, the ParallelElement's
* BufferTrait may need to "grow" if the new MediaElement has a
* larger buffer than any of its other children. In this case, the buffer of the
* ParallelElement adjusts to the size of its new child.
* </p>
*
* Here is how each trait is expressed when in parallel:
* <ul>
* <li>
* AudioTrait - The composite trait keeps the audible properties of all
* children in sync. When the volume of a child element (or the composite
* element) is changed, the volume is similarly changed for all audible
* children (and for the composite trait).
* </li>
* <li>
* BufferTrait - The composite trait is buffering if any child is buffering.
* Its length and size are the length and size of the child with the
* longest buffer. Its starting position is the minimum (earliest)
* starting position of all of its children.
* </li>
* <li>
* DisplayObjectTrait - If one or more of the composite’s children has the DisplayObjectTrait,
* the composite trait’s spatial dimensions are defined by the bounding box
* of the DisplayObject referenced by
* the <code>displayObject</code> property of the composite's DisplayObjectTrait.
* If none of the composite’s children has the DisplayObjectTrait,
* the composite trait's <code>mediaWidth</code> is the width of its widest child and its
* <code>mediaHeight</code> is the height of its tallest child.
* </li>
* <li>
* DRMTrait - The composite trait attempts to keep the DRM state of all children
* in sync. When a child element is authenticated, all DRM-enabled children are
* simultaneously authenticated.
* </li>
* <li>
* DVRTrait - The composite trait attempts to keep the DVR state of all children
* in sync.
* </li>
* <li>
* DynamicStreamTrait - The composite trait attempts to keep the dynamic streaming
* state of all children in sync. Specifically, it attempts to keep the
* <code>autoSwitch</code> property the same for all elements, and the current
* stream items within a similar bitrate range.
* </li>
* <li>
* LoadTrait - The composite trait keeps the load state of all children in
* sync. When a child element (or the composite element) is loaded, all
* loadable children (and the composite element) are simultaneously loaded.
* </li>
* <li>
* PlayTrait - The composite trait keeps the pause and play states of all children in
* sync. When a child element (or the composite element) is paused, all
* pausable children (and the composite element) are simultaneously paused.
* When a child element (or the composite element) is played, all
* playable children (and the composite element) are simultaneously played.
* </li>
* <li>
* SeekTrait - The composite trait keeps the seek state of all children in
* sync. When a child element (or the composite element) performs a seek,
* all seekable children (and the composite element) simultaneously perform
* that same seek.
* </li>
* <li>
* TimeTrait - The composite trait represents a timeline that encapsulates
* the timelines of all children. Its duration is the maximum of the
* durations of all children. Its position is kept in sync for all
* children, with the obvious caveat that a child's position will never be
* greater than its duration.
* </li>
* </ul>
*
* @includeExample ParallelElementExample.as -noswf
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public class ParallelElement extends CompositeElement
{
/**
* Constructor.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function ParallelElement()
{
super();
}
// Overrides
//
/**
* @private
*/
override protected function createMetadata():Metadata
{
var result:Metadata = super.createMetadata();
CompositeMetadata(result).mode = CompositionMode.PARALLEL;
return result;
}
/**
* @private
*/
override protected function processAggregatedTrait(traitType:String, trait:MediaTraitBase):void
{
super.processAggregatedTrait(traitType, trait);
var compositeTrait:MediaTraitBase = getTrait(traitType);
// Create the composite trait if it doesn't exist yet.
if (compositeTrait == null)
{
compositeTrait = traitFactory.createTrait
( traitType
, traitAggregator
, CompositionMode.PARALLEL
, this
);
if (compositeTrait != null)
{
addTrait(traitType, compositeTrait);
}
}
}
/**
* @private
*/
override protected function processUnaggregatedTrait(traitType:String, trait:MediaTraitBase):void
{
super.processUnaggregatedTrait(traitType, trait);
// Remove the composite trait if the unaggregated trait was the
// last child of the composite trait.
if (traitAggregator.hasTrait(traitType) == false)
{
removeTrait(traitType);
}
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.