Project Documentation

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:

  1. If the primary MIME type of the content is "image", the built in user-agent support will be used.
  2. 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.
  3. 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.
  4. If one player is especially dominant on the user agent and that player can play the media resource, that player will be used.
  5. 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.

Code 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" />

Supported Client Events for Client Behaviors

  • click (default)
  • dblclick
  • keydown
  • keypress
  • keyup
  • mousedown
  • mousemove
  • mouseout
  • mouseover
  • mouseup

Events

Type Phases Description
org.apache.myfaces.trinidad.event.AttributeChangeEventInvoke 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 event might include the width of a column that supported client-side resizing.

Attributes

Name Type Supports EL? Description
attributeChangeListenerjavax.el.MethodExpressionOnly 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.
autostartbooleanYes Default Value: false

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.
bindingorg.apache.myfaces.trinidad.component.core.output.CoreMediaOnly 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.
contentTypeStringYes 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.
controlsStringYes Valid Values: noneVisible, none, typical, all, minimal
Default Value: typical

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".
  • "none"

    don't show any controls for the media player and don't allow control access through alternate means, such as context menus.

    This value is typically only used in kiosk-type applications where no user control over the playing of the media is allowed. It is typically used in conjunction with setting the "autostart" attribute to "true", and the "playCount" attribute to "0" to cause the media play immediately and then loop.

  • "noneVisible"

    don't show any controls for the media player but allow control access through alternate means, such as context menus.

    This value is typically only used in applications where user control over the playing of the media is allowed, but not encouraged. It is typically used in conjunction with setting the "autostart" attribute to "true", and the "playCount" attribute to "0" to cause the media to play immediately and then loop.

  • "minimal"

    show a minimal set of controls for playing media on the media player.

    This value gives users control over the most important media playing controls, while occupying the least amount of additional space on the user agent.

  • "typical"

    show the typical set of controls for playing media on the media player.

    This value, the default, gives users control over the most common media playing controls, without occupying an inordinate amount of extra space on the user agent.

  • "all"

    Show all available controls for playing media on the media player

    Using this setting can cause large amount of additional space to be required, depending on the media player used.

The default of this attribute is "typical".

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

idStringNo the identifier for the component. The identifier must follow a subset of the syntax allowed in HTML:
  • Must not be a zero-length String.
  • First character must be an ASCII letter (A-Za-z) or an underscore ('_').
  • Subsequent characters must be an ASCII letter or digit (A-Za-z0-9), an underscore ('_'), or a dash ('-').
inlineStyleStringYes the CSS styles to use for this component.
innerHeightintYes 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.

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

onclickStringYes an onclick Javascript handler.
ondblclickStringYes an ondblclick Javascript handler.
onkeydownStringYes an onkeydown Javascript handler.
onkeypressStringYes an onkeypress Javascript handler.
onkeyupStringYes an onkeyup Javascript handler.
onmousedownStringYes an onmousedown Javascript handler.
onmousemoveStringYes an onmousemove Javascript handler.
onmouseoutStringYes an onmouseout Javascript handler.
onmouseoverStringYes an onmouseover Javascript handler.
onmouseupStringYes an onmouseup Javascript handler.
partialTriggersString[]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".

playCountintYes the number of times the media resource will play. If set to "0", the resource will loop until the user stops the playing.
playerStringYes 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.
  • "none"

    use a link in the user agent page to launch the playing of the media resource.

    This player setting uses the least amount of space on the page and uses the user agent's built in content type mapping to determine how to display the media resource.

  • "quicktime"

    use the Apple QuickTime player.

  • "windows"

    use the Windows Media Player.

  • "real"

    use the Real Player.

renderedbooleanYes Default Value: true

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). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component.
shortDescStringYes The short description of the component. This text is commonly used by user agents to display tooltip help text.
sourceStringYes 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.
standbyTextStringYes Message to display in the media player while the media resource is loading.
styleClassStringYes a CSS style class to use for this component.
widthStringYes 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.