Summary
Tag name:
<tr:media>
UIComponent class:
org.apache.myfaces.trinidad.component.core.output.CoreMedia
Component type:
org.apache.myfaces.trinidad.CoreMedia
The media component displays media content, such as audio, video, or image in a player embedded in the user agent. The media control displays the media specified by the "source" attribute in the appropriate media player. If a particular media player is desired, it can be specified using the "player" attribute. The media control attempts to intelligently handle two tricky aspects of cross-platform media display--determining the best player to display the media, and sizing the media player.
The media control attempts to pick the appropriate media player using the following steps:
- If the primary MIME type of the content is "image", the built in user-agent support will be used.
- If a media player has been specified by the "player" attribute and that player is available on the user agent and can display the media resource, that player will be used.
- If one player is especially good at playing the media resource and that player is available on the user agent, that player will be used.
- If one player is especially dominant on the user agent and that player can play the media resource, that player will be used.
- the "link" player will be used.
The media component supports two approaches to sizing the media control setting the "width" and "height" attributes, which specify the amount of space reserved on the user agent for the media control, and setting the "innerWidth" and "innerHeight" attributes, which specify the size of the media resource content. Since it is almost impossible to determine the correct width and height to use across different players and different player control configurations, specifying the "innerWidth" and "innerHeight" is the recommended strategy.
If the size of the media control isn't specified by one of the above approaches, a default inner size, determined by the content type of the media resource, will be used. This works well for audio content, but can cause content to be clipped or occupy too much space for video content.
Example(s):
This sample builds an media control, for playing a house music Windows Media file. The typical set of controls is displayed, and the control is sized just large enough to display the controls, since the default inner size of audio files is 0 by 0 pixels.
<tr:media source="house.wma" />
Events
Type | Phases | Description |
---|---|---|
org.apache.myfaces.trinidad.event.AttributeChangeEvent | Invoke Application, Apply Request Values |
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing. |
Attributes
Name | Type | Supports EL? | Description |
---|---|---|---|
attributeChangeListener | javax.el.MethodExpression | Only EL | a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing. |
autostart | boolean | Yes | a boolean value that controls whether the media resource loads and plays automatically without user initiation. When set to "true", the media resource will load and play as soon as possible. |
binding | org.apache.myfaces.trinidad.component. |
Only EL | an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean. |
contentType | String | Yes | the MIME type of the media content returned by the "source" URI. This attribute is used as a hint when determining which player to pick, how the controls of the player are to be configured, and the default size of the media player. If it isn't specified, an attempt will be made to derive this information from the extension of the source URI. |
controls | String | Yes | Valid Values:
noneVisible, none, typical, all, minimal the set of controls made available to the user for controlling the media playback. The actual set of controls displayed for the same value may differ between players. Likewise, the amount of space occupied by the controls will differ from media player to media player. This can cause problems if the size of the media control has been specified by the "width" and "height" attributes rather than "innerWidth" and "innerHeight".
The default of this attribute is |
height | String | Yes | height in pixels to reserve for the media player plus its content.
As the extra height needed for the media player controls can vary
from media player to media player and depend on the controls
displayed in the media player, it is recommended that the
"innerHeight" attribute be used in preference to this attribute.
If both the "height" and "innerHeight" attributes are specified, the "height" attribute will be used. If no height is specified, the height of the media control is determined by calculating the "innerHeight" and adding any extra height necessary to display the media player controls. |
id | String | No | the identifier for the component. The identifier
must follow a subset of the syntax allowed in HTML:
|
inlineStyle | String | Yes | the CSS styles to use for this component. |
innerHeight | int | Yes | height in pixels to reserve for the media player content. This
will typically be set to the pixel height of the media resource
to display.
If no "innerHeight" is specified, the "innerHeight" will be defaulted based on the content type of the media resource to play. If both the "height" and "innerHeight" attributes are specified, the "height" attribute will be used. |
innerWidth | int | Yes | width in pixels to reserve for the media player content. This
will typically be set to the pixel width of the media resource
to display.
If no "innerWidth" is specified, the "innerWidth" will be defaulted based on the content type of the media resource to play. If both the "width" and "innerWidth" attributes are specified, the "width" attribute will be used. |
onclick | String | Yes | an onclick Javascript handler. |
ondblclick | String | Yes | an ondblclick Javascript handler. |
onkeydown | String | Yes | an onkeydown Javascript handler. |
onkeypress | String | Yes | an onkeypress Javascript handler. |
onkeyup | String | Yes | an onkeyup Javascript handler. |
onmousedown | String | Yes | an onmousedown Javascript handler. |
onmousemove | String | Yes | an onmousemove Javascript handler. |
onmouseout | String | Yes | an onmouseout Javascript handler. |
onmouseover | String | Yes | an onmouseover Javascript handler. |
onmouseup | String | Yes | an onmouseup Javascript handler. |
partialTriggers | String[] | Yes |
the IDs of the components that should trigger a partial update.
This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too. Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2" Identifiers must account for NamingContainers. You can use a single colon to start the search from the root, or use multiple colons to move up through the NamingContainer. For example, "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), ":::" will pop out of two naming containers, etc. The search for the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the component with id = commandButton1 after popping out of two naming containers relative to this component. To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId". |
playCount | int | Yes | the number of times the media resource will play. If set to "0", the resource will loop until the user stops the playing. |
player | String | Yes | Valid Values:
windows, quicktime, link, real which media player to use to play the media resource. If possible, the media control will accomodate this request. However, if the requested player is not available on the user agent, or does not support playing the media resource, an alternate player will be used instead. In all cases, the "link" player is used as a fallback if no other player is available, or the requested player fails for some reason.
|
rendered | boolean | Yes | whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). |
shortDesc | String | Yes | The short description of the component. This text is commonly used by user agents to display tooltip help text. |
source | String | Yes | the URI specifying the location of the media resource. If no contentType is specified, the contentType will be inferred from the extension of the source attribute. |
standbyText | String | Yes | Message to display in the media player while the media resource is loading. |
styleClass | String | Yes | a CSS style class to use for this component. |
width | String | Yes | width in pixels to reserve for the media player plus its content.
As the extra width needed for the media player controls can vary
from media player to media player and depend on the controls
displayed in the media player, it is recommended that the
"innerWidth" attribute be used in preference to this attribute.
If both the "width" and "innerWidth" attributes are specified, the "width" attribute will be used. If no width is specified, the width of the media control is determined by calculating the "innerWidth" and adding any extra width necessary to display the media player controls. |