-
Notifications
You must be signed in to change notification settings - Fork 24
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
15 changed files
with
121 additions
and
126 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
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,3 @@ | ||
VITE_SORA_SIGNLAING_URL=wss://sora.example.com/signaling | ||
VITE_SORA_CHANNEL_ID=sora-js-sdk | ||
VITE_ACCESS_TOKEN=secret |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<html lang="ja"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Recvonly test</title> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<h1>Recvonly test</h1> | ||
<button id="start-recvonly">start</button> | ||
<button id="stop-recvonly">stop</button><br /> | ||
<div style="display: flex;"> | ||
<div id="remote-videos"></div> | ||
</div> | ||
</div> | ||
|
||
<script type="module" src="./main.js"></script> | ||
</script> | ||
</body> | ||
|
||
</html> |
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,48 @@ | ||
import Sora from '../../dist/sora.js' | ||
|
||
const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL | ||
const SORA_CHANNEL_ID = import.meta.env.VITE_SORA_CHANNEL_ID | ||
const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN | ||
|
||
const channelId = SORA_CHANNEL_ID | ||
const debug = false | ||
const sora = Sora.connection(SORA_SIGNALING_URL, debug) | ||
const metadata = { access_token: ACCESS_TOKEN } | ||
const options = {} | ||
|
||
const recvonly = sora.recvonly(channelId, metadata, options) | ||
|
||
recvonly.on('track', (event) => { | ||
const stream = event.streams[0] | ||
if (!stream) return | ||
const remoteVideoId = `remotevideo-${stream.id}` | ||
const remoteVideos = document.querySelector('#remote-videos') | ||
if (!remoteVideos.querySelector(`#${remoteVideoId}`)) { | ||
const remoteVideo = document.createElement('video') | ||
remoteVideo.id = remoteVideoId | ||
remoteVideo.style.border = '1px solid red' | ||
remoteVideo.autoplay = true | ||
remoteVideo.playsinline = true | ||
remoteVideo.controls = true | ||
remoteVideo.width = '320' | ||
remoteVideo.height = '240' | ||
remoteVideo.srcObject = stream | ||
remoteVideos.appendChild(remoteVideo) | ||
} | ||
}) | ||
|
||
recvonly.on('removetrack', (event) => { | ||
const remoteVideo = document.querySelector(`#remotevideo-${event.target.id}`) | ||
if (remoteVideo) { | ||
document.querySelector('#remote-videos').removeChild(remoteVideo) | ||
} | ||
}) | ||
|
||
document.querySelector('#start-recvonly').addEventListener('click', async () => { | ||
await recvonly.connect() | ||
}) | ||
|
||
document.querySelector('#stop-recvonly').addEventListener('click', async () => { | ||
await recvonly.disconnect() | ||
document.querySelector('#remote-videos').innerHTML = null | ||
}) |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sendonly test</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Sendonly test</h1> | ||
<div> | ||
<h2>sendonly1</h2> | ||
<button id="start-sendonly">start</button> | ||
<button id="stop-sendonly">stop</button><br /> | ||
<video id="sendonly-local-video" autoplay="" playsinline="" controls="" style="width: 320px; height: 240px; border: 1px solid black;"></video> | ||
</div> | ||
</div> | ||
|
||
<script src="./sora.js"></script> | ||
<script type="text/javascript"> | ||
</script> | ||
</body> | ||
</html> |
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,24 @@ | ||
import Sora from '../../dist/sora.js' | ||
|
||
const SORA_SIGNALING_URL = import.meta.env.VITE_SORA_SIGNALING_URL | ||
const SORA_CHANNEL_ID = import.meta.env.VITE_SORA_CHANNEL_ID | ||
const ACCESS_TOKEN = import.meta.env.VITE_ACCESS_TOKEN | ||
|
||
const channelId = SORA_CHANNEL_ID | ||
const debug = false | ||
const sora = Sora.connection(SORA_SIGNALING_URL, debug) | ||
const metadata = { access_token: ACCESS_TOKEN } | ||
const options = {} | ||
|
||
const sendonly = sora.sendonly(channelId, metadata, options) | ||
|
||
document.querySelector('#start-sendonly').addEventListener('click', async () => { | ||
const mediaStream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true }) | ||
await sendonly.connect(mediaStream) | ||
document.querySelector('#sendonly-local-video').srcObject = mediaStream | ||
}) | ||
|
||
document.querySelector('#stop-sendonly').addEventListener('click', async () => { | ||
await sendonly.disconnect() | ||
document.querySelector('#sendonly-local-video').srcObject = null | ||
}) |
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.