Skip to content

Latest commit

 

History

History
467 lines (337 loc) · 27.1 KB

File metadata and controls

467 lines (337 loc) · 27.1 KB

Playback

Overview

Operations for video playback management

Available Operations

createId

You can create a new playback ID for a specific media asset. If you have already retrieved an existing playbackId using the Get Media by ID endpoint for a media asset, you can use this endpoint to generate a new playback ID with a specified access policy.

If you want to create a private playback ID for a media asset that already has a public playback ID, this endpoint also allows you to do so by specifying the desired access policy.

How it works

  1. Make a POST request to this endpoint, replacing <mediaId> with the uploadId or id of the media asset.

  2. Include the accessPolicy in the request body with private or public as the value.

  3. You receive a response containing the newly created playback ID with the specified access level.

Example

A video streaming service generates playback IDs for each media file when users request to view specific content. The video player then uses the playback ID to stream the video.

Note: In the examples below, package hello.world; is used for demonstration purposes. When creating your own Java files, ensure the package name matches your directory structure (e.g., if your file is at src/main/java/com/example/MyApp.java, use package com.example;).

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.AccessPolicy;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.*;
import io.fastpix.sdk.utils.JSON;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        CreateMediaPlaybackIdResponse res = sdk.playback().createId()
                .mediaId("your-media-id")
                .body(CreateMediaPlaybackIdRequestBody.builder()
                    .accessPolicy(AccessPolicy.PUBLIC)
                    .drmConfigurationId("your-drm-configuration-id")
                    .resolution(Resolution.ONE_THOUSAND_AND_EIGHTYP)
                    .build())
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ The unique identifier assigned to the media when created. The value must be a valid UUID. your-media-id
body Optional<CreateMediaPlaybackIdRequestBody> Request body for creating playback id for an media

Response

CreateMediaPlaybackIdResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

list

Retrieves all playback IDs associated with a given media asset, including each playback ID’s access policy and detailed access restrictions such as allowed or denied domains and user agents.

How it works:

  1. Send a GET request to this endpoint with the target mediaId.
  2. The response includes an array of playback ID records with their respective access controls.

Use case: Useful for validating and managing playback permissions programmatically, reviewing restriction settings, or powering an access control dashboard.

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.ListPlaybackIdsResponse;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        ListPlaybackIdsResponse res = sdk.playback().list()
                .mediaId("your-media-id")
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ N/A your-media-id

Response

ListPlaybackIdsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

deleteId

This endpoint deletes a specific playback ID associated with a media asset. Deleting a playback ID revokes access to the media content linked to that ID.

How it works

  1. Make a DELETE request to this endpoint, replacing <mediaId> with the unique ID of the media asset from which you want to delete the playback ID.

  2. Include the playbackId you want to delete in the request body.

Example

Your platform offers limited-time access to premium content. When the subscription expires, you can revoke access to the content by deleting the associated playback ID, preventing users from streaming the video further.

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.DeleteMediaPlaybackIdResponse;
import io.fastpix.sdk.utils.JSON;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        DeleteMediaPlaybackIdResponse res = sdk.playback().deleteId()
                .mediaId("your-media-id")
                .playbackId("your-playback-id")
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ The unique identifier assigned to the media when created. The value must be a valid UUID. your-media-id
playbackId String ✔️ Return the universal unique identifier for playbacks which can contain a maximum of 255 characters. your-playback-id

Response

DeleteMediaPlaybackIdResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

get

This endpoint retrieves details about a specific playback ID associated with a media asset. Use it to check the access policy for that specific playback ID, such as whether it is public or private.

How it works:

  1. Make a GET request to the endpoint, replacing {mediaId} with the media ID and {playbackId} with the playback ID.
  2. This request is useful for auditing or validation before granting playback access in your application.

Example: A media platform might use this endpoint to verify if a playback ID is public or private before embedding the video in a frontend player or allowing access to a restricted group.

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.GetPlaybackIdResponse;
import io.fastpix.sdk.utils.JSON;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        GetPlaybackIdResponse res = sdk.playback().get()
                .mediaId("your-media-id")
                .playbackId("your-playback-id")
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ N/A your-media-id
playbackId String ✔️ N/A your-playback-id

Response

GetPlaybackIdResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

updateDomainRestrictions

This endpoint updates domain-level restrictions for a specific playback ID associated with a media asset. It allows you to restrict playback to specific domains or block known unauthorized domains.

How it works:

  1. Make a PATCH request to this endpoint with your desired domain access configuration.
  2. Set a default policy (allow or deny) and specify domain names in the allow or deny lists.
  3. This is commonly used to restrict video playback to your website or approved client domains.

Example: A streaming service can allow playback only from example.com and deny all others by setting: "defaultPolicy": "deny" and "allow": ["example.com"].

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import java.util.List;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.UpdateDomainRestrictionsRequestBody;
import io.fastpix.sdk.models.operations.UpdateDomainRestrictionsResponse;
import io.fastpix.sdk.utils.JSON;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        UpdateDomainRestrictionsResponse res = sdk.playback().updateDomainRestrictions()
                .mediaId("your-media-id")
                .playbackId("your-playback-id")
                .body(UpdateDomainRestrictionsRequestBody.builder()
                    .allow(List.of(
                        "yourdomain.com",
                        "sampledomain.com"))
                    .deny(List.of(
                        "yourworkdomain.com"))
                    .build())
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ N/A your-media-id
playbackId String ✔️ N/A your-playback-id
body UpdateDomainRestrictionsRequestBody ✔️ N/A

Response

UpdateDomainRestrictionsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*

updateUserAgentRestrictions

This endpoint allows updating user-agent restrictions for a specific playback ID associated with a media asset. It can be used to allow or deny specific user-agents during playback request evaluation.

How it works:

  1. Make a PATCH request to this endpoint with your desired user-agent access configuration.
  2. Specify a default policy (allow or deny) and provide specific allow or deny lists.
  3. Use this to restrict access to specific browsers, devices, or bots.

Example: A developer may configure a playback ID to deny access from known scraping user-agents while allowing all others by default.

Example Usage

// Package declaration - adjust to match your project's directory structure
package hello.world;

// Import required classes from the FastPix SDK
import java.lang.Exception;
import java.util.List;
import com.fasterxml.jackson.databind.SerializationFeature;
import io.fastpix.sdk.FastPixSDK;
import io.fastpix.sdk.models.components.Security;
import io.fastpix.sdk.models.operations.UpdateUserAgentRestrictionsRequestBody;
import io.fastpix.sdk.models.operations.UpdateUserAgentRestrictionsResponse;
import io.fastpix.sdk.utils.JSON;

public class Application {

    public static void main(String[] args) throws Exception {

        FastPixSDK sdk = FastPixSDK.builder()
                .security(Security.builder()
                    .username("your-access-token")
                    .password("your-secret-key")
                    .build())
            .build();

        UpdateUserAgentRestrictionsResponse res = sdk.playback().updateUserAgentRestrictions()
                .mediaId("your-media-id")
                .playbackId("your-playback-id")
                .body(UpdateUserAgentRestrictionsRequestBody.builder()
                    .allow(List.of(
                        "Mozilla/55.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"))
                    .deny(List.of(
                        "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/53745.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36"))
                    .build())
                .call();

        if (res.object().isPresent()) {
            var mapper = JSON.getMapper();
            mapper.enable(SerializationFeature.INDENT_OUTPUT);
            System.out.println(mapper.writeValueAsString(res.object().get()));
        }
    }
}

Parameters

Parameter Type Required Description Example
mediaId String ✔️ N/A your-media-id
playbackId String ✔️ N/A your-playback-id
body UpdateUserAgentRestrictionsRequestBody ✔️ N/A

Response

UpdateUserAgentRestrictionsResponse

Errors

Error Type Status Code Content Type
models/errors/APIException 4XX, 5XX */*