Package ro.sync.ecss.extensions.commons
Class MediaObjectsUtil
- java.lang.Object
-
- ro.sync.ecss.extensions.commons.MediaObjectsUtil
-
@API(type=INTERNAL, src=PUBLIC) public final class MediaObjectsUtil extends java.lang.Object
Utility methods for media objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]
ALLOWED_MEDIA_EXTENSIONS
All the allowed extensions for an media file.static java.lang.String[]
MEDIA_AUDIO_EXTENSIONS
Audio files extenstions.static java.lang.String[]
MEDIA_VIDEO_EXTENSIONS
Video files Extensions.static java.lang.String[]
RECOGNIZED_MEDIA_HOSTS
All accepted media hosts.static java.lang.String
REFERENCE_ATTR_DATA
Attribute "data".static java.lang.String
REFERENCE_ATTR_DATAKEYREF
Attribute "data key reference".
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsExtension(java.lang.String extension, java.lang.String[] allowedExtensions)
Determine if an extension is found in an extension array.static java.lang.String
correctMediaEmbeddedReference(java.lang.String url)
Corrects YouTube and Vimeo video references transforming the link into an embedded links.static java.lang.String
detectOutputclass(java.lang.String href)
Detects the output class of an media object by comparing object's href with the recognized extensions list.static boolean
hasAudioFormat(java.lang.String format)
Checks if the format is a supported audio format.static boolean
hasVideoFormat(java.lang.String format)
Checks if the format is a supported video format.static boolean
isAudioReference(java.lang.String fileName)
Checks if the extension of file name is a reference to supported audio types.static boolean
isEmbeddedContent(java.lang.String url)
Determines if the referred resource is YouTube or Vimeo embedded content.static boolean
isMediaReference(java.net.URL url)
Checks if the URL is a media reference and an media object (not xref) should be inserted.static boolean
isRecognizedAsMedia(java.lang.String hostURL)
Determine if the host of an inserted video should be treated as media object.static boolean
isVideoReference(java.lang.String fileName)
Checks if the extension of file name is a reference to supported video types.
-
-
-
Field Detail
-
REFERENCE_ATTR_DATA
public static final java.lang.String REFERENCE_ATTR_DATA
Attribute "data".- See Also:
- Constant Field Values
-
REFERENCE_ATTR_DATAKEYREF
public static final java.lang.String REFERENCE_ATTR_DATAKEYREF
Attribute "data key reference".- See Also:
- Constant Field Values
-
MEDIA_AUDIO_EXTENSIONS
public static final java.lang.String[] MEDIA_AUDIO_EXTENSIONS
Audio files extenstions.
-
MEDIA_VIDEO_EXTENSIONS
public static final java.lang.String[] MEDIA_VIDEO_EXTENSIONS
Video files Extensions.
-
ALLOWED_MEDIA_EXTENSIONS
public static final java.lang.String[] ALLOWED_MEDIA_EXTENSIONS
All the allowed extensions for an media file.
-
RECOGNIZED_MEDIA_HOSTS
public static final java.lang.String[] RECOGNIZED_MEDIA_HOSTS
All accepted media hosts.
-
-
Method Detail
-
containsExtension
public static boolean containsExtension(java.lang.String extension, java.lang.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 java.lang.String detectOutputclass(java.lang.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(java.net.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(java.lang.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(java.lang.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 java.lang.String correctMediaEmbeddedReference(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String format)
Checks if the format is a supported video format.- Parameters:
format
- resource format.- Returns:
true
if the format is video.
-
-