-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
792 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# singo JavaScript SDK | ||
|
||
singoのJavaScript SDKです。 | ||
|
||
## Install | ||
|
||
``` | ||
npm i --save singo-sdk | ||
``` | ||
or | ||
``` | ||
yarn add singo-sdk | ||
``` | ||
|
||
## Usage (example) | ||
|
||
```js | ||
const myScreen = document.querySelector('#my-screen') | ||
|
||
// コンストラクタで自分の画面のvideo要素を渡します。 | ||
const client = new SingoClient(myScreen, { | ||
signalingServerEndpoint: 'ws://localhost:5000' | ||
}) | ||
|
||
// joinRoomメソッドで特定の名前のroomへ入ります。 | ||
// ここではvideoタグを追加して表示しています | ||
await c.joinRoom('room name') | ||
|
||
// onTrackは新たなclientのstreamを受け取ったときに呼ばれます | ||
c.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タグを削除しています。 | ||
c.onLeave = ((clientId) => { | ||
const elId = `#partner-${clientId}`; | ||
const pre = document.getElementById(elId); | ||
pre?.parentNode.removeChild(pre); | ||
}); | ||
``` |
Oops, something went wrong.