Class MediaObjectsUtil

java.lang.Object
ro.sync.ecss.extensions.commons.MediaObjectsUtil

@API(type=INTERNAL, src=PUBLIC) public final class MediaObjectsUtil extends Object
Utility methods for media objects.
  • Field Details

    • REFERENCE_ATTR_DATA

      public static final String REFERENCE_ATTR_DATA
      Attribute "data".
      See Also:
    • REFERENCE_ATTR_DATAKEYREF

      public static final String REFERENCE_ATTR_DATAKEYREF
      Attribute "data key reference".
      See Also:
    • MEDIA_AUDIO_EXTENSIONS

      public static final String[] MEDIA_AUDIO_EXTENSIONS
      Audio files extenstions.
    • MEDIA_VIDEO_EXTENSIONS

      public static final String[] MEDIA_VIDEO_EXTENSIONS
      Video files Extensions.
    • ALLOWED_MEDIA_EXTENSIONS

      public static final String[] ALLOWED_MEDIA_EXTENSIONS
      All the allowed extensions for an media file.
    • RECOGNIZED_MEDIA_HOSTS

      public static final String[] RECOGNIZED_MEDIA_HOSTS
      All accepted media hosts.
  • Method Details

    • containsExtension

      public static boolean containsExtension(String extension, String[] allowedExtensions)
      Determine if an extension is found in an extension array.
      Parameters:
      extension - Searched extension.
      allowedExtensions - Array with the allowed extensions.
      Returns:
      true if the extension is contained.
    • detectOutputclass

      public static String detectOutputclass(String href)
      Detects the output class of an media object by comparing object's href with the recognized extensions list. If an extension is not found, the selected type is iFrame.
      Parameters:
      href - The file href.
      Returns:
      Detected output class.
    • isMediaReference

      public static boolean isMediaReference(URL url)
      Checks if the URL is a media reference and an media object (not xref) should be inserted.
      Parameters:
      url - Resource's URL.
      Returns:
      true if the resource is a media. YouTube and Vimeo links are associated with media files.
    • isEmbeddedContent

      public static boolean isEmbeddedContent(String url)
      Determines if the referred resource is YouTube or Vimeo embedded content.
      Parameters:
      url - the referred resource.
      Returns:
      true if the referred resource is YouTube or Vimeo embedded video.
    • isRecognizedAsMedia

      public static boolean isRecognizedAsMedia(String hostURL)
      Determine if the host of an inserted video should be treated as media object.
      Parameters:
      hostURL - Video host (like YouTube or Vimeo)
      Returns:
      true if the host is contained.
    • correctMediaEmbeddedReference

      public static String correctMediaEmbeddedReference(String url)
      Corrects YouTube and Vimeo video references transforming the link into an embedded links.
       YouTube: From https://www.youtube.com/watch?v=video_id To https://www.youtube.com/embed/video_id
       Vimeo  : From https://vimeo.com/video_id To https://player.vimeo.com/video/video_id
       
      Parameters:
      url - The inserted media reference.
      Returns:
      The corrected media reference.
    • isAudioReference

      public static boolean isAudioReference(String fileName)
      Checks if the extension of file name is a reference to supported audio types.
      Parameters:
      fileName - The name of the file to check.
      Returns:
      true if current file name points to an audio file.
    • hasAudioFormat

      public static boolean hasAudioFormat(String format)
      Checks if the format is a supported audio format.
      Parameters:
      format - resource format.
      Returns:
      true if the format is audio.
    • isVideoReference

      public static boolean isVideoReference(String fileName)
      Checks if the extension of file name is a reference to supported video types.
      Parameters:
      fileName - The name of the file to check.
      Returns:
      true if current file name points to a video file.
    • hasVideoFormat

      public static boolean hasVideoFormat(String format)
      Checks if the format is a supported video format.
      Parameters:
      format - resource format.
      Returns:
      true if the format is video.