Reference Source Test
public class | source

Assets

Extends:

events~EventEmittersrc/base.js~Base → Assets

Assets Class - Provides access to the Mux Video Assets API

Example:

const { Video } = new Mux(accessToken, secret);

// Create an asset
Video.Assets.create({input: 'https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4'});

Test:

Method Summary

Public Methods
public

create(params: Object): Promise

Creates a Mux asset with the specified JSON parameters

public

createPlaybackId(assetId: string, params: Object): Promise

Create an asset playback id

public

createTrack(assetId: string, params: Object): Promise

Create a subtitle text track

public

del(assetId: string): Promise

Deletes a Mux asset

public

deletePlaybackId(assetId: string, playbackId: string): Promise

Delete an asset playback ID

public

deleteTrack(assetId: string, trackId: string): Promise

Delete an asset text track

public

get(assetId: string): Promise

Get an asset

public

inputInfo(assetId: string): Promise

Get input info for an asset

public

list(params: *): Promise

List all assets for a Mux Environment (tied to your access token)

public

playbackId(assetId: string, playbackId: string): Promise

Return an asset playback id

public

Update master access for an asset

public

Update mp4 support for an asset

Public Methods

public create(params: Object): Promise source

Creates a Mux asset with the specified JSON parameters

Params:

NameTypeAttributeDescription
params Object

Asset JSON parameters (e.g input)

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Create an asset
Video.Assets.create({input: 'https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4'});

Test:

See:

public createPlaybackId(assetId: string, params: Object): Promise source

Create an asset playback id

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

params Object

Asset JSON parameters (e.g playback_policy)

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Create an asset playback ID
Video.Assets.createPlaybackId(assetId, { policy: 'public' });

See:

public createTrack(assetId: string, params: Object): Promise source

Create a subtitle text track

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

params Object

subtitle text track JSON parameters

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Create an asset text track
Video.Assets.createTrack(assetId, {
  url: "https://example.com/myVIdeo_en.srt",
  type: "text",
  text_type: "subtitles",
  language_code: "en-US",
});

Test:

See:

public del(assetId: string): Promise source

Deletes a Mux asset

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset intended for deletion

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Delete an asset
Video.Assets.del(assetId);

Test:

See:

public deletePlaybackId(assetId: string, playbackId: string): Promise source

Delete an asset playback ID

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

playbackId string

The ID for the asset playback ID to delete

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Delete an asset playback ID
Video.Assets.deletePlaybackId(assetId, { policy: 'public' });

Test:

See:

public deleteTrack(assetId: string, trackId: string): Promise source

Delete an asset text track

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

trackId string

The ID for the asset text track to delete

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Delete an asset text track
Video.Assets.deleteTrack(assetId, trackId);

Test:

See:

public get(assetId: string): Promise source

Get an asset

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Get an asset
Video.Assets.get(assetId);

Test:

See:

public inputInfo(assetId: string): Promise source

Get input info for an asset

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Get input info for an asset
Video.Assets.inputInfo(assetId);

Test:

See:

public list(params: *): Promise source

List all assets for a Mux Environment (tied to your access token)

Params:

NameTypeAttributeDescription
params *

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// List all assets for a Mux Environment
Video.Assets.list();

Test:

See:

public playbackId(assetId: string, playbackId: string): Promise source

Return an asset playback id

Params:

NameTypeAttributeDescription
assetId string

The ID for the asset

playbackId string

The ID for the playbackId

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Retrieve an asset playbackId
Video.Assets.playbackId(assetId, playbackId);

Test:

See:

public updateMasterAccess(params: Object): Promise source

Update master access for an asset

Params:

NameTypeAttributeDescription
params Object

master access JSON parameters

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Update master access for an asset
Video.Assets.updateMasterAccess(assetId, {master_access: "temporary"});

See:

public updateMp4Support(params: Object): Promise source

Update mp4 support for an asset

Params:

NameTypeAttributeDescription
params Object

mp4 support JSON parameters

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Updates mp4 support for an asset
Video.Assets.updateMp4Support(assetId, {mp4_support: "standard"});

See: