Skip to content

FastPix/fastpix-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastPix Unity SDK

A Unity-Native, Developer-Friendly SDK for Seamless Integration with the FastPix Platform API

Introduction

The FastPix Unity SDK simplifies integration with the FastPix platform directly within your Unity projects. It provides a interface for secure and efficient communication with the FastPix API, enabling easy management of media uploads, live streaming, on-demand content, playlists, video analytics, and signing keys for secure access and token management.

Key Features

Media API

  • Upload Media: Seamlessly upload media files from URLs or local devices.
  • Manage Media: List, fetch, update, and delete media assets with ease.
  • Playback IDs: Generate and manage playback IDs for secure and flexible media access.
  • Advanced Media Tools: Generate video summaries, chapters, named entities, subtitles, and perform content moderation.
  • Playlist Management: Create and manage playlists, add or remove media, and adjust playback order.
  • DRM Support: Configure and manage DRM settings for protected content.

Live API

  • Create & Manage Live Streams: Effortlessly create, list, update, and delete live streams.
  • Control Stream Access: Generate playback IDs to manage viewer access securely.
  • Stream Management: Enable, disable, or complete streams with fine-grained control.
  • Simulcast to Multiple Platforms: Broadcast live content to multiple platforms simultaneously.

Signing Keys

  • Create Signing Keys: Generate signing keys for secure token-based access.
  • List & Retrieve Keys: Fetch all keys or get details for a specific key.
  • Manage Keys: Delete or revoke signing keys to maintain secure access control.

Video Data API

  • View Analytics: List video views, get detailed view information, and track top-performing content.
  • Concurrent Viewer Insights: Access timeseries data for live and on-demand streams.
  • Custom Reporting: Filter viewers by dimensions, list breakdowns, and compare metrics across datasets.
  • Error Tracking & Diagnostics: Retrieve logs and analyze errors for proactive monitoring.

For detailed usage, refer to the FastPix API Reference.

Prerequisites:

Getting started with FastPix:

To get started with the FastPix Unity SDK, ensure you have the following:

  • The FastPix APIs are authenticated using an Access Token and a Secret Key. You must generate these credentials to use the SDK.

  • Follow the steps in the Authentication with Access Tokens guide to obtain your credentials.


Table of Contents

SDK Installation

The SDK can either be compiled using dotnet build and the resultant .dll file can be copied into your Unity project's Assets folder, or you can copy the source code directly into your project.

The SDK relies on Newtonsoft's JSON.NET Package which can be installed via the Unity Package Manager.

To do so open the Package Manager via Window > Package Manager and click the + button then Add package from git URL... and enter com.unity.nuget.newtonsoft-json and click Add.

SDK Example Usage

Example

using fastpix.io;
using fastpix.io.Models.Components;
using System.Collections.Generic;

var sdk = new Fastpix(security: new Security() {
        username="your-access-token"
        Password = "secret-key",
    });

CreateMediaRequest req = new CreateMediaRequest() {
    Inputs = new List<fastpix.io.Models.Components.Input>() {
        Input.CreateVideoInput(
            new VideoInput() {
                Type = "video",
                Url = "https://static.fastpix.io/sample.mp4",
            },
        ),
    },
    Metadata = new Dictionary<string, string>() {
        { "key1", "value1" },
    },
    AccessPolicy = CreateMediaRequestAccessPolicy.Public,
    MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp,
};


using(var res = await sdk.InputVideo.CreateMediaAsync(req))
{
    // handle response
}

Available Resources and Operations

Available methods

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default, an API error will raise a fastpix.io.Models.Errors.APIException exception, which has the following properties:

Property Type Description
Message string The error message
StatusCode int The raw HTTP response
RawResponse HttpResponseMessage The raw HTTP response
Body string The response content

When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the CreateMediaAsync method throws the following exceptions:

Error Type Status Code Content Type
fastpix.io.Models.Errors.BadRequestException 400 application/json
fastpix.io.Models.Errors.InvalidPermissionException 401 application/json
fastpix.io.Models.Errors.ForbiddenException 403 application/json
fastpix.io.Models.Errors.ValidationErrorResponse 422 application/json
fastpix.io.Models.Errors.APIException 4XX, 5XX */*

Example

using fastpix.io;
using fastpix.io.Models.Components;
using System;
using fastpix.io.Models.Errors;
using System.Collections.Generic;

var sdk = new Fastpix(security: new Security() {
        username="your-access-token"
        Password = "secret-key",
    });

CreateMediaRequest req = new CreateMediaRequest() {
    Inputs = new List<fastpix.io.Models.Components.Input>() {
        Input.CreateVideoInput(
            new VideoInput() {
                Type = "video",
                Url = "https://static.fastpix.io/sample.mp4",
            },
        ),
    },
    Metadata = new Dictionary<string, string>() {
        { "key1", "value1" },
    },
    AccessPolicy = CreateMediaRequestAccessPolicy.Public,
    MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp,
};

try
{
    using(var res = await sdk.InputVideo.CreateMediaAsync(req))
    {
            // handle response
    }
}
catch (Exception ex)
{
    if (ex is BadRequestException)
    {
        // handle exception
    }
    else if (ex is InvalidPermissionException)
    {
        // handle exception
    }
    else if (ex is ForbiddenException)
    {
        // handle exception
    }
    else if (ex is ValidationErrorResponse)
    {
        // handle exception
    }
    else if (ex is fastpix.io.Models.Errors.APIException)
    {
        // handle exception
    }
}

Server Selection

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:

using fastpix.io;
using fastpix.io.Models.Components;
using System.Collections.Generic;

var sdk = new Fastpix(
    serverUrl: "https://api.fastpix.io/v1/",
    security: new Security() {
        username="your-access-token"
        Password = "secret-key",
    });

CreateMediaRequest req = new CreateMediaRequest() {
    Inputs = new List<fastpix.io.Models.Components.Input>() {
        Input.CreateVideoInput(
            new VideoInput() {
                Type = "video",
                Url = "https://static.fastpix.io/sample.mp4",
            },
        ),
    },
    Metadata = new Dictionary<string, string>() {
        { "key1", "value1" },
    },
    AccessPolicy = CreateMediaRequestAccessPolicy.Public,
    MaxResolution = CreateMediaRequestMaxResolution.OneThousandAndEightyp,
};


using(var res = await sdk.InputVideo.CreateMediaAsync(req))
{
    // handle response
}

Development

Maturity

This SDK is currently in beta, and breaking changes may occur between versions even without a major version update. To avoid unexpected issues, we recommend pinning your dependency to a specific version. This ensures consistent behavior unless you intentionally update to a newer release.

Detailed Usage

For a complete understanding of each API's functionality, including request and response details, parameter descriptions, and additional examples, please refer to the FastPix API Reference.

The API reference provides comprehensive documentation for all available endpoints and features, ensuring developers can integrate and utilize FastPix APIs efficiently.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages