Usecase: videoRoom

videoRoom

VideoRoom usecase


new videoRoom(onEvents, domElements, options)

VideoRoom usecase

Parameters:
Name Type Description
onEvents object

Event handlers: onEvents

domElements object

DOM elements: domElements

options object

Available options: options

Returns:

VideoRoom actions

Type
Promise
Example
var onEvents = {
    onCreated: id => {
         // Videoroom ID created
    },
    onError: (cause, code) => {
         // An error has occurred
    },
    onJoined: () => {
         // You've joined the Videoroom
    },
    onDestroyed: () => {
         // Videoroom ID destroyed
    },
    onPeerJoined: (id, display) => {
         // A new peer has joined the videoroom
    },
    onPeerLeft: (id, display) => {
         // A new peer has left the videoroom
    },
    onReadyLocalStream: (isReady, stream) => {
          // The local video stream is or not ready
    }
};

var domElements = {
    videos: document.getElementById('videortc-videos') // App container
};

var options = {
    stream: {
        audioEnabled: true,
        videoEnabled: true,
        aDeviceId: null,
        vDeviceId: null,
        resolution: 'vga' // 'qvga', 'vga', 'hd', 'full-hd', '4k', '8k',
        frameRate: 30,
        voiceProcessor: false
    },
    account: "******" // Multiple mode
};

usecases.videoRoom(onEvents, domElements, options)
    .then(action => {
         // Use Case has been atacched succesfully
         ...
    })
    .catch(cause => {
        // Error attaching the Use Case
        Janus.error("Error Attach " + cause );
    })

Methods


closeUsecase()

Close the current UseCase. It's recommended combine with disconnect method

Returns:
Type
nothing
Example
action.closeUsecase();
myVideoApp.disconnect(); // Recommended

createVideoroom(isPrivate, adminKey, userKey, quality, maxPublishers, isRecord, roomId)

Creates a new VideoRoom / Conference

Parameters:
Name Type Description
isPrivate Boolean

Is private?

adminKey string

Administrator Room Key (Destroy)

userKey string

User Room Key (Join)

quality string | enum

Quality: "high", "medium" or "low"

maxPublishers integer

Number of publishers/peers

isRecord Boolean

Record the videoroom

roomId integer

Unique numeric ID (Optional)

Returns:
Type
nothing
Example
action.createVideoroom(true, 'MyP455w0rd', 'Us3rPw', 'medium', 6, false);

destroyVideoroom(id, adminKey)

Destroys a Videoroom (Admin key is required)

Parameters:
Name Type Description
id integer

VideoRoom Id

adminKey string

Administrator Room Key

Returns:
Type
nothing
Example
action.destroyVideoroom(743267423, 'MyP455w0rd');

getPeers()

Gets the number of peers/users connected into the current Videoroom

Returns:

Number of peers/users connected into the current Videoroom

Type
integer
Example
action.getPeers(); // Number of peers

joinVideoroom(name, idRoom, pin)

Join into a VideoRoom

Parameters:
Name Type Description
name string

User Name

idRoom integer

VideoRoom ID

pin string

Videoroom PIN to Join (Optional)

Returns:
Type
nothing
Example
action.joinVideoroom('Mike', 743267423, 'ivr1234');

replaceVideo(type)

Replace the local Video track

Parameters:
Name Type Description
type string

('user', 'environment', 'left', 'right' or 'next')

Example
action.replaceVideo('environment');

toggleAudio()

Toggle Audio stream (Mute/Unmute)

Returns:

Is audio muted?

Type
boolean
Example
action.toggleAudio(); // true or false

toggleVideo()

Toggle Video stream (Mute/Unmute)

Returns:

Is video muted?

Type
boolean
Example
action.toggleVideo(); // true or false