The org.osmf.traits package provides the building blocks for creating specific media traits. Traits define the capabilities of a media element.
Different implementations of a media element aggregate different sets of traits, depending on the characteristics of the media they represent. For example, an audio element may aggregate the IAudible, IPlayable, ITemporal and ILoadable traits. These individual traits define the capabilities of the media element independently of the specific media element implementation. For a media element that has the ILoadable trait, the trait provides the media element's load and unload capability. Similarly, the implementation of the IPlayable trait provides media element's ability to play itself.
A trait is added to a media element through the element's MediaElement.addTrait()
method.
Implementation of media traits is predicated on the following principles:
- Traits are independent of one another. Therefore, a media trait does not extend another media trait.
- Traits dispatch their own events. Trait implementations can derive from the MediaTraitBase class, which extends EventDispatcher and implements IMediaTrait, to handle event dispatching.
- Traits are identified by the MediaTraitType enumeration class.
- Traits should be implemented as separate classes.
The traits interfaces are intended for use by media element classes. They are generic outward-facing entities characterized primarily by getters without setters, except for traits that require externally settable properties, such as the volume or pan properties of an IAudible.
The base trait classes are intended for use by implementations that subclass MediaElement. They generally have both setters and getters.
Class | Description | |
---|---|---|
AlternativeAudioTrait | AlternativeAudioTrait defines the trait interface for media supporting alternative audio streams. | |
AudioTrait | AudioTrait defines the trait interface for media that have audio. | |
BufferTrait | BufferTrait defines the trait interface for media that can use a data buffer. | |
DisplayObjectTrait | DisplayObjectTrait defines the trait interface for media that expose a DisplayObject, and which may have intrinsic dimensions. | |
DRMState | DRMState is the enumeration of possible DRM-specific states that a piece of media can be in. | |
DRMTrait | DRMTrait defines the trait interface for media which can be protected by digital rights management (DRM) technology. | |
DVRTrait | DVRTrait defines the trait interface for media that can be played while in the process of being recorded, as if with a digital video recorder (DVR). | |
DynamicStreamTrait | DynamicStreamTrait defines the trait interface for media supporting dynamic stream switching. | |
LoaderBase | LoaderBase is the base class for objects that are capable of loading and unloading LoadTraits. | |
LoadState | LoadState is the enumeration of possible states that a LoadTrait can be in. | |
LoadTrait | LoadTrait defines the trait interface for media that must be loaded before it can be presented. | |
MediaTraitBase | A MediaTraitBase is the encapsulation of a trait or capability that's inherent to a MediaElement. | |
MediaTraitType | MediaTraitType is the enumeration of all possible media trait types. | |
PlayState | PlayState is the enumeration of possible states that a PlayTrait can be in. | |
PlayTrait | PlayTrait defines the trait interface for media whose playback can be started and stopped. | |
SeekTrait | SeekTrait defines the trait interface for media that can be instructed to jump to a position in time. | |
TimeTrait | TimeTrait defines the trait interface for media that have a duration and a currentTime. | |
TraitEventDispatcher | TraitEventDispatcher is a utility class that exposes a uniform interface for receiving trait events from a MediaElement. |
Thu Dec 6 2018, 01:47 PM -08:00