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