All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cloudinary.asset.Video.kt Maven / Gradle / Ivy

Go to download

Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline. Upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more. This Java library allows to easily integrate with Cloudinary in Kotlin applications.

The newest version!
package com.cloudinary.asset

import com.cloudinary.config.CloudConfig
import com.cloudinary.config.UrlConfig
import com.cloudinary.transformation.Action
import com.cloudinary.transformation.Format
import com.cloudinary.transformation.ITransformable
import com.cloudinary.transformation.Transformation
import com.cloudinary.transformation.VideoTransformation

class Video(
    // config
    cloudConfig: CloudConfig,
    urlConfig: UrlConfig,

    // fields
    version: String? = null,
    publicId: String? = null,
    extension: Format? = null,
    urlSuffix: String? = null,
    deliveryType: String? = null,
    signature: String? = null,
    private val transformation: VideoTransformation? = null
) : BaseAsset(
    cloudConfig,
    urlConfig,
    version,
    publicId,
    extension,
    urlSuffix,
    ASSET_TYPE_VIDEO,
    deliveryType,
    signature
) {
    class Builder(cloudConfig: CloudConfig, urlConfig: UrlConfig) :
        BaseAssetBuilder(cloudConfig, urlConfig, ASSET_TYPE_VIDEO), ITransformable {

        private var transformation: VideoTransformation? = null

        fun transformation(transformation: VideoTransformation) = apply { this.transformation = transformation }
        fun transformation(transform: VideoTransformation.Builder.() -> Unit) = apply {
            val builder = VideoTransformation.Builder()
            builder.transform()
            this.transformation = builder.build()
        }

        override fun add(action: Action) = apply {
            this.transformation = (this.transformation ?: VideoTransformation()).add(action)
        }

        override fun addTransformation(transformation: Transformation)= apply { (this.transformation ?: VideoTransformation()).add(transformation.toString()) }

        fun build() = Video(
            cloudConfig,
            urlConfig,
            version,
            publicId,
            extension,
            urlSuffix,
            deliveryType,
            signature,
            transformation
        )
    }

    override fun getTransformationString() = transformation?.toString()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy