Tips
This page has not been translated yet.
Plugin の使い方
Core ライブラリでは Plugin を使って追加の機能を利用できます。
現在提供されている Plugin は以下の 1 種類です。
- SFU Bot
SFU Bot を例に Plugin の登録方法を以下に示します。
// SkyWayContextを作成する const context = await SkyWayContext.Create(tokenString); // pluginのインスタンスを作成する const plugin = new SfuBotPlugin(); // SkyWayContextにpluginを登録する context.registerPlugin(plugin);
各 Plugin の詳しい使い方は各 Plugin の API リファレンスを参照してください。
カメラやマイクの切り替え
Publication の replaceStream API を使うことで、Publication の Stream を変更できます。
Stream を Publish した後に Publication の Stream を別のデバイスのカメラの Stream に入れ替える方法を以下に示します。
const devices = await SkyWayStreamFactory.enumerateInputVideoDevices(); const camera = await SkyWayStreamFactory.createCameraVideoStream({ deviceId: devices[0].id }); const publication = await person.publish(camera); const anotherCamera = await SkyWayStreamFactory.createCameraVideoStream({ deviceId: devices[1].id }); publication.replaceStream(anotherCamera);
メディア通信の状態取得(getStats)
メディア通信(WebRTC)の状態を取得する方法について説明します。
※状態取得 API の形式は今後変更される予定があります。
LocalStream
ユーザーが送信する側の Stream(LocalStream)の通信状態を取得する方法
// subscriberIdはLocalStreamを受信しているMemberのID // subscriberIdのMemberとの通信状態が取得できる const stats = await localStream.getStats(subscriberId);
RemoteStream
ユーザーが受信している Stream(RemoteStream)の通信状態を取得する方法
const stats = await remoteStream.getStats();
リモートの Member に Publication を Subscribe させる
Token の members scope を次のように設定することで、リモートの Member に任意の Publication を Subscribe させたり Unsubscribe させることができます。
const members = [ { id: '*', name: '*', actions: ['write'], publication: { actions: ['write'], }, subscription: { actions: ['write'], }, }, ];
サンプルコード
//... const person: LocalPerson = await channel.join({ name: 'alice' }); const video = await SkyWayStreamFactory.createCameraVideoStream(); const publication = await localPerson.publish(video); const remoteMember = channel.members.find((member) => member.name === 'bob'); const remoteSubscription = await remoteMember.subscribe(publication);
リモートのメンバーの Subscription の stream を参照することはできません(stream プロパティの中身は常に undefined になります)