Menu

[r200]: / trunk / framework / OSMF / org / osmf / traits / MediaTraitBase.as  Maximize  Restore  History

Download this file

136 lines (131 with data), 5.5 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
/*****************************************************
*
* 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.traits
{
import flash.events.EventDispatcher;
/**
* A MediaTraitBase is the encapsulation of a trait or capability that's
* inherent to a MediaElement. The sum of all traits on a media element
* define the overall capabilities of the media element.
*
* <p>Media traits are first-class members of the object model for a
* number of reasons:</p>
* <ul>
* <li>
* Traits allow us to isolate common aspects of different media types into
* reusable building blocks. For example, music and video may share a
* common implementation for audio. An "audio" trait can encapsulate
* that common implementation in such a way that it can be used for both
* media types, while still providing a uniform interface to these
* different media types.
* </li>
* <li>
* Different media elements may have their capabilities change dynamically
* over time, and traits allow us to isolate these capabilities in such
* a way that we can clearly express that dynamism. For example, a video
* player might not initially be "viewable", due to its need to be loaded
* before playback can begin. Rather than express this dynamism through
* changes to a set of methods on a monolithic media class, we can express
* it through the presence or absence of a trait instance on a lighter
* weight media class.
* </li>
* <li>Traits make compositioning scalable. (Compositioning is the ability
* to temporally and spatially composite collections of media.) If traits
* represent the overall vocabulary of the media framework, then we can
* implement compositioning primarily in terms of the traits, rather than
* in terms of the media that aggregate those traits. This approach allows
* developers to create new media implementations that can easily integrate
* with the compositioning parts of the framework without requiring changes
* to that framework. Our working assumption, of course, is that most (if
* not all) media will generally share the same vocabulary, which can be
* expressed through a core set of media traits.
* </li>
* <li>Traits allow for uniform, media-agnostic <i>client</i> classes. For
* example, if a client class is capable of rendering the "display object" trait,
* then it's capable of rendering any and all media that host that trait. </li>
* </ul>
*
* <p>It's important to be aware of the relationship between a media trait
* and a media element. Some media trait implementations will be tightly
* coupled to a specific type of media element, while others will be
* generic enough to work with any media element. For example, an
* implementation of a "play" trait that works with video is typically
* going to be specific to one class of media elements, namely the class
* that plays video, since the playback operations will be specific to the
* underlying implementation of video (i.e. NetStream). On the other hand,
* an implementation of a "display object" trait might be able to work with
* any media element, since DisplayObjectTrait will use the same underlying
* media implementation (DisplayObject) for any media element.</p>
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public class MediaTraitBase extends EventDispatcher
{
/**
* Constructor.
*
* @param traitType The MediaTraitType for this trait. All possible values
* are described on the MediaTraitType enumeration.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function MediaTraitBase(traitType:String)
{
super();
_traitType = traitType;
}
/**
* The MediaTraitType for this trait.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function get traitType():String
{
return _traitType;
}
/**
* Disposes of any resources used by this trait. Called by the framework
* whenever a trait is removed from a MediaElement.
*
* <p>Subclasses should override to do any disposal logic specific to their
* implementation.</p>
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion OSMF 1.0
*/
public function dispose():void
{
}
private var _traitType:String;
}
}
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.