1.0.9 • Published 3 years ago

@100mslive/hmsvideo-web v1.0.9

Weekly downloads
1,184
License
MIT
Repository
-
Last release
3 years ago

hmsvideo-sdk

Endpoint Healthcheck

Web SDK for the 100mslive backend.

Installation

npm install @100mslive/hmsvideo-web

Usage

import { HMSPeer, HMSClientConfig, HMSClient, HMSMediaStreamConstraints } from "@100mslive/hmsvideo-web';

const peer = new HMSPeer(userName:"<userName here>",authToken:"<authToken here>")
const config = new HMSClientConfig({
    endpoint: "<endpoint URL here>"
})
const client = new HMSClient(peer, config)

// Setup handlers
client.on('connect',() => {
    // This is where we can call `join(room)`
});
client.on('disconnect', () => {});
client.on('peer-join', (room, peer) => {
    // Show a notification or toast message in the UI
});
client.on('peer-leave', (room, peer) => {
    // Show a notification or toast message in the UI
});
client.on('stream-add', (room, peer,  streamInfo) => {
    // subscribe to the stream if needed
});
client.on('stream-remove', (room, peer, streamInfo) => {
    // Remove remote stream if needed
});
client.on('broadcast', (room, peer ,message) => {
    // Show a notification or update chat UI
});

// Connect
try {
    await client.connect()
} catch(err) {
    // Handle error
}


// Join a room using a unique room id
const room = <some unique room id>
try {
    await client.join(room);
} catch(err) {
    // Handle error
}


// Get a local stream
const constraints = new HMSMediaStreamConstraints()
try {
    const localStream = await client.getLocalStream(constraints: HMSMediaStreamConstraints);
} catch(err) {
    // Handle error
}


// Publish local stream
try {
    await client.publish(localStream, room);
} catch(err) {
    // handle the error
}


// Unpublish local stream
try {
    await client.unpublish(localStream, room);
} catch(err) {
    // handle error
}


// Subscribe to a remote stream
try {
    const remoteStream = await client.subscribe(mid, roomId);
    // Do something with remoteStream
} catch(err) {
    // Handle error
}


// Unsubscribe from a stream
try {
    await client.unsubscribe(remoteStream, roomId);
} catch(err) {
    // Handle error
}


// Broadcast a payload to the room
try {
    await client.broadcast(payload, roomId);
} catch(err) {
    // Handle error
}


// Close client connection
client.disconnect();
1.0.9

3 years ago

1.0.9-1

3 years ago

1.0.9-0

3 years ago

1.0.8

3 years ago

1.0.8-0

3 years ago

1.0.7

3 years ago

1.0.7-0

3 years ago

1.0.6

3 years ago

1.0.6-1

3 years ago

1.0.6-0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.3-2

3 years ago

1.0.3-1

3 years ago

1.0.3-0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.9.27-2

3 years ago

0.9.27-1

3 years ago

0.9.26

3 years ago

0.9.26-2

3 years ago

0.9.25

3 years ago

0.9.25-0

3 years ago

0.9.25-1

3 years ago

0.9.25-2

3 years ago

0.9.23-12

3 years ago

0.9.24

3 years ago

0.9.23-11

3 years ago

0.9.23-9

3 years ago

0.9.23-7

3 years ago

0.9.23-5

3 years ago

0.9.23-4

3 years ago

0.9.23-3

3 years ago

0.9.23-1

3 years ago

0.9.23-2

3 years ago

0.9.23-0

3 years ago

0.9.22

3 years ago

0.9.21-0

3 years ago

0.9.20

3 years ago

0.9.20-1

3 years ago

0.9.19

3 years ago

0.9.17

3 years ago

0.9.18

3 years ago

0.9.15

3 years ago

0.9.16

3 years ago

0.9.15-4

3 years ago

0.9.15-3

3 years ago

0.9.15-2

3 years ago

0.9.15-1

3 years ago

0.9.15-0

3 years ago

0.9.14

3 years ago

0.9.12-1

3 years ago

0.9.12-0

3 years ago

0.9.11-1

3 years ago

0.9.11-0

3 years ago

0.9.9

3 years ago

0.9.10

3 years ago

0.9.8

3 years ago

0.9.8-0

3 years ago

0.9.7

3 years ago

0.9.7-1

3 years ago

0.9.4

3 years ago

0.9.6

3 years ago

0.9.4-0

3 years ago

0.9.3

3 years ago

0.9.3-0

3 years ago

0.9.2

3 years ago

0.9.1-4

3 years ago

0.9.1-3

3 years ago

0.9.1-2

3 years ago

0.9.1-1

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.9.1-0

3 years ago

0.8.5-7

3 years ago

0.8.5-6

3 years ago

0.8.5-5

3 years ago

0.8.5-4

3 years ago

0.8.5-2

3 years ago

0.8.3

3 years ago

0.8.5-0

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago