Class Youtube

All Implemented Interfaces:
HasAttribute<Youtube>, HasClassName<Youtube>, HasStyle<Youtube>

@NodeName("iframe") @InlineStyleSheet(id="dwcj-youtube-widget", once=true, value="[dwcj-youtube-container] {\n width: 100%;\n /* Keep it the right aspect-ratio */\n aspect-ratio: 16/9;\n overflow: hidden !important;\n}\n\n[dwcj-youtube-container] iframe {\n /* Extend it beyond the viewport... */\n width: 300%;\n height: 100%;\n /* ...and bring it back again */\n margin-left: -100%;\n}\n") public class Youtube extends ElementComposite implements HasAttribute<Youtube>, HasClassName<Youtube>, HasStyle<Youtube>
The Youtube component is a component that allows you to embed a youtube video in your application.

For instance, to embed a youtube video in your application you can do the following:

 
 Youtube youtube = new Youtube();
 youtube.setVideoId("youtube-video-id");
 youtube.setAutoPlay(true);
 youtube.setLoop(true);
 youtube.setControls(false);
 youtube.setMute(true);
 
 

Author:
Hyyan Abo Fakher
  • Constructor Details

    • Youtube

      public Youtube()
      Create a new youtube component.
    • Youtube

      public Youtube(String id)
      Create a new youtube component with the given id.
      Parameters:
      id - the id of the youtube video
  • Method Details

    • setVideoId

      public Youtube setVideoId(String id)
      Specifies the ID of the YouTube video to be played.
      Parameters:
      id - the id of the youtube video
      Returns:
      the youtube component
    • getVideoId

      public String getVideoId()
      Get the id of the youtube video.
      Returns:
      the id of the youtube video
    • setAutoPlay

      public Youtube setAutoPlay(Boolean autoplay)
      Enable or disable the autoplay.

      Specifies whether the initial video will automatically start to play when the player loads.

      Parameters:
      autoplay - the autoplay property
      Returns:
      the youtube component
    • isAutoPlay

      public Boolean isAutoPlay()
      Check if the autoplay is enabled.
      Returns:
      true if the autoplay is enabled, false otherwise
    • setCaptionLanguage

      public Youtube setCaptionLanguage(String language)
      Specifies the default language that the player will use to display captions.

      Set the option's value to an ISO 639-1 two-letter language code. If you use this option and also set the showCaption then the player will show captions in the specified language when the player loads. If you do not also set the showCaption option, then captions will not display by default, but will display in the specified language if the user opts to turn captions on.

      Parameters:
      language - the default language
      Returns:
      the youtube component
    • getCaptionLanguage

      public String getCaptionLanguage()
      Get the default language.
      Returns:
      the default language
    • setCaption

      public Youtube setCaption(Boolean showCaption)
      When enabled causes closed captions to be shown by default, even if the user has turned captions off. The default behavior is based on user preference.
      Parameters:
      showCaption - the load caption property
      Returns:
      the youtube component
    • isCaption

      public Boolean isCaption()
      Check if the load caption is enabled.
      Returns:
      true if the load caption is enabled, false otherwise
    • setControls

      public Youtube setControls(Boolean controls)
      Show or hide the player controls.
      Parameters:
      controls - when true, the player controls are shown, hidden otherwise.
      Returns:
      the youtube component
    • isControls

      public Boolean isControls()
      Check if the controls are shown.
      Returns:
      true if the controls are shown, false otherwise
    • setDisableKeyboard

      public Youtube setDisableKeyboard(Boolean disableKeyboard)
      Enable or disable the keyboard controls.
      Parameters:
      disableKeyboard - when true causes the player to not respond to keyboard controls.
      Returns:
      the youtube component
    • isDisableKeyboard

      public Boolean isDisableKeyboard()
      Check if keyboard interactions are disabled.
      Returns:
      the disableKeyboard property
    • setEnd

      public Youtube setEnd(int end)
      Specifies the time, measured in seconds from the start of the video, when the player should stop playing the video.
      Parameters:
      end - the end time
      Returns:
      the youtube component
    • getEnd

      public int getEnd()
      Get the end time.
      Returns:
      the end time
    • setFullScreenButton

      public Youtube setFullScreenButton(Boolean fullScreen)
      Enable or disable the fullscreen button.
      Parameters:
      fullScreen - when false, prevents the fullscreen button from displaying in the player. by default the button will display.
      Returns:
      the youtube component
    • isFullScreenButton

      public Boolean isFullScreenButton()
      Check if the fullscreen button is enabled.
      Returns:
      true if the fullscreen button is enabled, false otherwise
    • setLanguage

      public Youtube setLanguage(String language)
      Sets the player's interface language.

      The option value is an ISO 639-1 two-letter language code or a fully specified locale. For example, fr and fr-ca are both valid values. Other language input codes, such as IETF language tags (BCP 47) might also be handled properly. The interface language is used for tooltips in the player and also affects the default caption track. Note that YouTube might select a different caption track language for a particular user based on the user's individual language preferences and the availability of caption tracks.

      Parameters:
      language - the language
      Returns:
      the youtube component
    • getLanguage

      public String getLanguage()
      Get the language.
      Returns:
      the language
      See Also:
    • setShowAnnotations

      public Youtube setShowAnnotations(Boolean showAnnotations)
      Enable or disable the video annotations.
      Parameters:
      showAnnotations - true to show the annotations, false otherwise to hide.
      Returns:
      the youtube component
    • isShowAnnotations

      public Boolean isShowAnnotations()
      Check if the annotations are enabled.
      Returns:
      true if the annotations are enabled, false otherwise
    • setList

      public Youtube setList(String list)
      The list option, in conjunction with the setListType(ListType) option, identifies the content that will load in the player.
      Parameters:
      list - the list
      Returns:
      the youtube component
    • getList

      public String getList()
      Get the list.
      Returns:
      the list
    • setListType

      public Youtube setListType(Youtube.ListType listType)
      The listType option, in conjunction with the list option, identifies the content that will load in the player.
      Parameters:
      listType - the list type
      Returns:
      the youtube component
    • getListType

      public Youtube.ListType getListType()
      Get the list type.
      Returns:
      the list type
    • setLoop

      public Youtube setLoop(Boolean loop)
      Automatically play the video again and again.

      In the case of a single video player, enabling the option causes the player to play the initial video again and again. In the case of a playlist player the player plays the entire playlist and then starts again at the first video.

      Parameters:
      loop - the loop property
      Returns:
      the youtube component
    • isLoop

      public Boolean isLoop()
      Check if the loop is enabled.
      Returns:
      true if the loop is enabled, false otherwise
    • setModestBranding

      public Youtube setModestBranding(Boolean modestBranding)
      A Boolean value that indicates whether the YouTube player does not show a YouTube logo.

      When true then prevents the YouTube logo from displaying in the control bar. Note that a small YouTube text label will still display in the upper-right corner of a paused video when the user's mouse pointer hovers over the player.

      Parameters:
      modestBranding - when true, the YouTube logo is not shown, shown otherwise.
      Returns:
      the youtube component
    • isModestBranding

      public Boolean isModestBranding()
      Get the modestBranding property.
      Returns:
      the modestBranding property
    • setPlaylist

      public Youtube setPlaylist(String playlist)
      Specifies a comma-separated list of video IDs to play.

      If you specify a value, the first video that plays will be the video id specified, and the videos specified in the playlist parameter will play thereafter.

      Parameters:
      playlist - the playlist property
      Returns:
      the youtube component
    • getPlaylist

      public String getPlaylist()
      Get the list of videos to play.
      Returns:
      the playlist property
    • setPlaysInline

      public Youtube setPlaysInline(Boolean playsinline)
      Controls whether videos play inline or fullscreen on iOS.

      when false, then results in fullscreen playback. This is currently the default value. when true, then results in inline playback for mobile browsers and for WebViews created with the allowsInlineMediaPlayback property set to YES.

      Parameters:
      playsinline - true to play inline, false otherwise
      Returns:
      the youtube component
    • isPlaysInline

      public Boolean isPlaysInline()
      Get the playsinline property.
      Returns:
      the playsinline property
    • setStart

      public Youtube setStart(int start)
      Set the start time.

      Causes the player to begin playing the video at the given number of seconds from the start of the video.

      Parameters:
      start - the start time
      Returns:
      the youtube component
    • getStart

      public int getStart()
      Get the start time.
      Returns:
      the start time
    • setMute

      public Youtube setMute(Boolean mute)
      Set the mute property.
      Parameters:
      mute - the mute property
      Returns:
      the youtube component
    • getMute

      public Boolean getMute()
      Get the mute property.
      Returns:
      the mute property
    • getUrl

      public String getUrl()
      Get the URL of the video.
      Returns:
      the URL of the video
    • addClassName

      public Youtube addClassName(String... className)
      Specified by:
      addClassName in interface HasClassName<Youtube>
    • removeClassName

      public Youtube removeClassName(String... className)
      Specified by:
      removeClassName in interface HasClassName<Youtube>
    • setStyle

      public Youtube setStyle(String property, String value)
      Specified by:
      setStyle in interface HasStyle<Youtube>
    • getStyle

      public String getStyle(String property)
      Specified by:
      getStyle in interface HasStyle<Youtube>
    • removeStyle

      public Youtube removeStyle(String property)
      Specified by:
      removeStyle in interface HasStyle<Youtube>
    • getComputedStyle

      public String getComputedStyle(String property)
      Specified by:
      getComputedStyle in interface HasStyle<Youtube>
    • getAttribute

      public String getAttribute(String attribute)
      Specified by:
      getAttribute in interface HasAttribute<Youtube>
    • setAttribute

      public Youtube setAttribute(String attribute, String value)
      Specified by:
      setAttribute in interface HasAttribute<Youtube>
    • removeAttribute

      public Youtube removeAttribute(String attribute)
      Specified by:
      removeAttribute in interface HasAttribute<Youtube>