0.1.2 • Published 4 years ago

singo-sdk v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

singo JavaScript SDK

singoのJavaScript SDKです。

Install

npm i --save singo-sdk

or

yarn add singo-sdk

Usage (example)

const myScreen = document.querySelector('#my-screen')

// コンストラクタで自分の画面のvideo要素を渡します。
const client = new SingoClient(myScreen, {
  signalingServerEndpoint: 'ws://localhost:5000'
})

// joinRoomメソッドで特定の名前のroomへ入ります。
// ここではvideoタグを追加して表示しています
await client.joinRoom('room name')

// onTrackは新たなclientのstreamを受け取ったときに呼ばれます
client.onTrack = ((clientId, stream) => {
  const elId = `#partner-${clientId}`;
  const pre = document.getElementById(elId);
  pre?.parentNode.removeChild(pre);

  const $video = document.createElement('video') as HTMLVideoElement;
  $video.id = elId;
  $video.setAttribute('autoplay', 'true')
  $video.setAttribute('playsinline', 'true')
  $video.setAttribute('muted', 'true')
  const pa = document.querySelector('#partners');
  pa.appendChild($video);
  $video.srcObject = stream;
});

// onLeaveはclientが退出したときに呼ばれます。
// ここでは退出したclientのvideoタグを削除しています。
client.onLeave = ((clientId) => {
  const elId = `#partner-${clientId}`;
  const pre = document.getElementById(elId);
  pre?.parentNode.removeChild(pre);
});

// close
client.close()
0.1.2

4 years ago

0.1.1

4 years ago

0.0.12

4 years ago

0.0.14

4 years ago

0.1.0

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago