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 StringAttribute "data".static final StringAttribute "data key reference". -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsExtension(String extension, String[] allowedExtensions) Determine if an extension is found in an extension array.static StringCorrects YouTube and Vimeo video references transforming the link into an embedded links.static StringdetectOutputclass(String href) Detects the output class of an media object by comparing object's href with the recognized extensions list.static booleanhasAudioFormat(String format) Checks if the format is a supported audio format.static booleanhasVideoFormat(String format) Checks if the format is a supported video format.static booleanisAudioReference(String fileName) Checks if the extension of file name is a reference to supported audio types.static booleanisEmbeddedContent(String url) Determines if the referred resource is YouTube or Vimeo embedded content.static booleanisMediaReference(URL url) Checks if the URL is a media reference and an media object (not xref) should be inserted.static booleanisRecognizedAsMedia(String hostURL) Determine if the host of an inserted video should be treated as media object.static booleanisVideoReference(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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif current file name points to an audio file.
-
hasAudioFormat
Checks if the format is a supported audio format.- Parameters:
format- resource format.- Returns:
trueif 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:
trueif current file name points to a video file.
-
hasVideoFormat
Checks if the format is a supported video format.- Parameters:
format- resource format.- Returns:
trueif the format is video.
-