Class MediaComponent

All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<Serializable,Component>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable
Direct Known Subclasses:
Audio, Video

public abstract class MediaComponent extends WebMarkupContainer
The media component is used to provide basic functionality to the video and audio component.
Since:
7.0.0
Author:
Tobias Soloschenko, Andrew Lombardi
See Also:
  • Constructor Details

    • MediaComponent

      public MediaComponent(String id)
      Constructor.
      Parameters:
      id - The component id
    • MediaComponent

      public MediaComponent(String id, IModel<?> model)
      Constructor.
      Parameters:
      id - The component id
      model - The component model
    • MediaComponent

      public MediaComponent(String id, ResourceReference resourceReference)
      Creates a media component
      Parameters:
      id - The component id
      resourceReference - the resource reference of the media file
    • MediaComponent

      public MediaComponent(String id, IModel<?> model, ResourceReference resourceReference)
      Creates a media component
      Parameters:
      id - The component id
      model - the internally used model
      resourceReference - the resource reference of the media file
    • MediaComponent

      public MediaComponent(String id, ResourceReference resourceReference, PageParameters pageParameters)
      Creates a media component
      Parameters:
      id - The component id
      resourceReference - the resource reference of the media file
      pageParameters - the page parameters to be used to be prepended to the media URL
    • MediaComponent

      public MediaComponent(String id, IModel<?> model, ResourceReference resourceReference, PageParameters pageParameters)
      Creates a media component
      Parameters:
      id - The component id
      model - the internally used model
      resourceReference - the resource reference of the media file
      pageParameters - the page parameters to be used to be prepended to the media URL
    • MediaComponent

      public MediaComponent(String id, String url)
      Creates a media component
      Parameters:
      id - The component id
      url - an external URL to be used for the media component
    • MediaComponent

      public MediaComponent(String id, IModel<?> model, String url)
      Creates a media component
      Parameters:
      id - The component id
      model - the internally used model
      url - an external URL to be used for the media component
    • MediaComponent

      public MediaComponent(String id, IModel<?> model, String url, PageParameters pageParameters)
      Creates a media component
      Parameters:
      id - The component id
      model - the internally used model
      url - an external URL to be used for the media component
      pageParameters - the page parameters to be used to be prepended to the media URL
  • Method Details

    • onComponentTag

      protected void onComponentTag(ComponentTag tag)
      Description copied from class: Component
      Processes the component tag. Overrides of this method most likely should call the super implementation.
      Overrides:
      onComponentTag in class Component
      Parameters:
      tag - Tag to modify
    • isAutoplay

      public boolean isAutoplay()
      If the playback is autoplayed on load
      Returns:
      If the playback is autoplayed on load
    • setAutoplay

      public void setAutoplay(boolean autoplay)
      Sets the playback to be autoplayed on load
      Parameters:
      autoplay - If the playback is autoplayed on load
    • isLooping

      public boolean isLooping()
      If the playback is looped
      Returns:
      If the playback is looped
    • setLooping

      public void setLooping(boolean loop)
      Sets the playback to be looped
      Parameters:
      loop - If the playback is looped
    • getPageParameters

      Gets the page parameter applied to the URL of the media component
      Returns:
      the page parameter applied to the URL of the media component
    • setPageParameters

      public void setPageParameters(PageParameters pageParameters)
      Sets the page parameter applied to the URL of the media component
      Parameters:
      pageParameters - the page parameter which are going to be applied to the URL of the media component
    • isMuted

      public boolean isMuted()
      If the playback is muted initially
      Returns:
      If the playback is muted initially
    • setMuted

      public void setMuted(boolean muted)
      Sets the playback muted initially
      Parameters:
      muted - If the playback is muted initially
    • hasControls

      public boolean hasControls()
      If the controls are going to be displayed
      Returns:
      if the controls are going to displayed
    • setControls

      public void setControls(Boolean controls)
      Sets if the controls are going to be displayed
      Parameters:
      controls - if the controls are going to displayed
    • getPreload

      The type of preload
      Returns:
      the preload
      See Also:
    • setPreload

      public void setPreload(MediaComponent.Preload preload)
      Sets the type of preload.
      • none: Hints to the user agent that either the author does not expect the user to need the media resource, or that the server wants to minimise unnecessary traffic.
      • metadata: Hints to the user agent that the author does not expect the user to need the media resource, but that fetching the resource metadata (dimensions, first frame, track list, duration, etc) is reasonable.
      • auto: Hints to the user agent that the user agent can put the user's needs first without risk to the server, up to and including optimistically downloading the entire resource.

      Parameters:
      preload - the type of the preload
    • getStartTime

      public String getStartTime()
      Gets the position at which the media component starts the playback
      Returns:
      the time at which position the media component starts the playback
      See Also:
    • setStartTime

      public void setStartTime(String startTime)
      Sets the position at which the media component starts the playback

      t=10,20
      t=npt:10,20

      t=120s,121.5s
      t=npt:120,0:02:01.5

      t=smpte-30:0:02:00,0:02:01:15
      t=smpte-25:0:02:00:00,0:02:01:12.1

      t=clock:20090726T111901Z,20090726T121901Z
      Parameters:
      startTime - the time at which position the media component starts the playback
    • getEndTime

      public String getEndTime()
      Gets the position at which the media component stops the playback
      Returns:
      the time at which position the media component stops the playback
      See Also:
    • setEndTime

      public void setEndTime(String endTime)
      Sets the position at which the media component stops the playback

      t=10,20
      t=npt:10,20

      t=120s,121.5s
      t=npt:120,0:02:01.5

      t=smpte-30:0:02:00,0:02:01:15
      t=smpte-25:0:02:00:00,0:02:01:12.1

      t=clock:20090726T111901Z,20090726T121901Z
      Parameters:
      endTime - the time at which position the media component stops the playback
    • getMediaGroup

      Gets the media group.
      Returns:
      the media group
    • setMediaGroup

      public void setMediaGroup(String mediaGroup)
      Sets the media group
      Parameters:
      mediaGroup - to be set
    • getCrossOrigin

      Gets the cross origin settings
      Returns:
      the cross origins settings
      See Also:
    • setCrossOrigin

      public void setCrossOrigin(MediaComponent.Cors crossOrigin)
      Sets the cross origin settings

      ANONYMOUS: Cross-origin CORS requests for the element will not have the credentials flag set.

      USER_CREDENTIALS: Cross-origin CORS requests for the element will have the credentials flag set.

      NO_CORS: The empty string is also a valid keyword, and maps to the Anonymous state. The attribute's invalid value default is the Anonymous state. The missing value default, used when the attribute is omitted, is the No CORS state
      Parameters:
      crossOrigin - the cross origins settings to set
    • getType

      public String getType()
      Gets the type
      Returns:
      the type of this media element
      See Also:
    • setType

      public void setType(String type)
      Sets the type

      * The following list shows some examples of how to use the codecs= MIME parameter in the type attribute.

      H.264 Constrained baseline profile video (main and extended video compatible) level 3 and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
      H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="avc1.58A01E, mp4a.40.2"'>
      H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="avc1.4D401E, mp4a.40.2"'>
      H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="avc1.64001E, mp4a.40.2"'>
      MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="mp4v.20.8, mp4a.40.2"'>
      MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container
      <source src='video.mp4' type='video/mp4; codecs="mp4v.20.240, mp4a.40.2"'>
      MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container
      <source src='video.3gp' type='video/3gpp; codecs="mp4v.20.8, samr"'>
      Theora video and Vorbis audio in Ogg container
      <source src='video.ogv' type='video/ogg; codecs="theora, vorbis"'>
      Theora video and Speex audio in Ogg container
      <source src='video.ogv' type='video/ogg; codecs="theora, speex"'>
      Vorbis audio alone in Ogg container
      <source src='audio.ogg' type='audio/ogg; codecs=vorbis'>
      Speex audio alone in Ogg container
      <source src='audio.spx' type='audio/ogg; codecs=speex'>
      FLAC audio alone in Ogg container
      <source src='audio.oga' type='audio/ogg; codecs=flac'>
      Dirac video and Vorbis audio in Ogg container
      <source src='video.ogv' type='video/ogg; codecs="dirac, vorbis"'>
      Theora video and Vorbis audio in Matroska container
      <source src='video.mkv' type='video/x-matroska; codecs="theora, vorbis"'>
      Parameters:
      type - the type of this media element