Reference Source Test
public class | source

LiveStreams

Extends:

* → LiveStreams

Live Streams Class - Provides access to the Mux Video Live Streams API

Example:

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

// Create a live stream
Video.LiveStreams.create({
 playback_policy: 'public',
 new_asset_settings: { playback_policy: 'public' }
});

Test:

Method Summary

Public Methods
public

create(params: Object): Promise

Creates a Mux live stream with the specified JSON parameters

public

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

Create a live stream playback id

public

createSimulcastTarget(liveStreamId: string, params: Object): Promise

Create a simulcast target

public

del(liveStreamId: string): Promise

Deletes a Mux Live Stream

public

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

Delete a live stream playback ID

public

deleteSimulcastTarget(liveStreamId: string, simulcastTargetId: string): Promise

Delete a simulcast target

public

disable(liveStreamId: string): Promise

Disable a Live Stream

public

enable(liveStreamId: string): Promise

Enable a Live Stream

public

get(liveStreamId: string): Promise

Get an Live Stream

public

getSimulcastTarget(liveStreamId: string, simulcastTargetId: string): Promise

Get a simulcast target

public

list(params: *): Promise

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

public

resetStreamKey(liveStreamId: string): Promise

Reset a stream key

public

signalComplete(liveStreamId: string): Promise

Signal a live stream is finished

Public Methods

public create(params: Object): Promise source

Creates a Mux live stream with the specified JSON parameters

Params:

NameTypeAttributeDescription
params Object

Live Stream JSON parameters (e.g playback_policy)

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Create a live stream
Video.LiveStreams.create({
 playback_policy: 'public',
 new_asset_settings: { playback_policy: 'public' }
});

See:

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

Create a live stream playback id

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

params Object

Live Stream 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 a live stream playback ID
Video.LiveStreams.createPlaybackId(liveStreamId, { policy: 'public' });

Test:

See:

public createSimulcastTarget(liveStreamId: string, params: Object): Promise source

Create a simulcast target

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

params Object

Simulcast Target JSON parameters (e.g url and stream_key)

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Create a live simulcast target
Video.LiveStreams.createSimulcastTarget(liveStreamId, {url: 'rtmp://live.example.com/app', stream_key: 'difvbfgi', passthrough: 'Example Live Streaming service'});

Test:

See:

public del(liveStreamId: string): Promise source

Deletes a Mux Live Stream

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream intended for deletion

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Delete a mux live stream
Video.LiveStreams.del(liveStreamId);

Test:

See:

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

Delete a live stream playback ID

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

playbackId string

The ID for the live stream 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 a live stream playback ID
Video.LiveStreams.deletePlaybackId(liveStreamId, { policy: 'public' });

Test:

See:

public deleteSimulcastTarget(liveStreamId: string, simulcastTargetId: string): Promise source

Delete a simulcast target

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

simulcastTargetId string

The ID for the simulcast target to delete

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Delete a simulcast target
Video.LiveStreams.deleteSimulcastTarget(liveStreamId, simulcastTargetId);

Test:

See:

public disable(liveStreamId: string): Promise source

Disable a Live Stream

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Disable a live stream
Video.LiveStreams.disable(liveStreamId);

Test:

See:

public enable(liveStreamId: string): Promise source

Enable a Live Stream

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Enable a Live Stream
Video.LiveStreams.enable(liveStreamId);

Test:

See:

public get(liveStreamId: string): Promise source

Get an Live Stream

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Get a live stream
Video.LiveStreams.get(liveStreamId);

Test:

See:

public getSimulcastTarget(liveStreamId: string, simulcastTargetId: string): Promise source

Get a simulcast target

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

simulcastTargetId string

The ID for the simulcast target to delete

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Get a live simulcast target
Video.LiveStreams.getSimulcastTarget(liveStreamId, simulcastTargetId);

Test:

See:

public list(params: *): Promise source

List all live streams 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 live streams for a Mux Environment
Video.LiveStreams.list();

Test:

See:

public resetStreamKey(liveStreamId: string): Promise source

Reset a stream key

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Reset a live stream key if you want to immediately stop the current stream key
// from working and create a new stream key that can be used for future broadcasts.
Video.LiveStreams.resetStreamKey(liveStreamId);

Test:

See:

public signalComplete(liveStreamId: string): Promise source

Signal a live stream is finished

Params:

NameTypeAttributeDescription
liveStreamId string

The ID for the live stream

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

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

// Signal a live stream is finished
Video.LiveStreams.signalComplete(liveStreamId);

Test:

See: