Browser
브라우저로 간단한 방송 앱을 개발합니다.
준비사항
가장 쉬운 방송앱 개발
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
video#localVideo { width:auto; height: 80%; background-color: black; }
button#connectChannelButton { position:absolute; overflow:visible; left:50%; top:10px; }
html,body { height:100%; }
</style>
<title>Remon JS Simple Test</title>
</head>
<body>
<video id="localVideo" autoplay controls class="video"></video>
<input type="text" class="btn" id="chidText"></input>
<button id="connectChannelButton" class="btn btn-sm" onclick="start();">Create</button>
</body>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="https://remotemonster.com/sdk/remon.min.js"></script>
<script>
let isConnected = false;
const chidTextEl = document.querySelector('#chidText');
const config = { credential: {
key: '1234567890', serviceId: 'SERVICEID1'
},
view: {
local: '#localVideo'
},
media: {
audio:true,
video:true,
sendonly: true
}
};
const listener = {
onCreateChannel(channelId) {
console.log(`EVENT FIRED: onCreateChannel: ${channelId}`);
chidTextEl.value=channelId;
}
}
const remon = new Remon({ config:config, listener:listener });
function start() {
if (isConnected === false){
isConnected = true;
document.getElementById("connectChannelButton").innerHTML = "Close";
remon.createRoom('testroom');
}else{
isConnected = false;
document.getElementById("connectChannelButton").innerHTML = "Create";
remon.disconnect();
}
}
</script>
</html>Callback 이벤트 처리기 사용하기
Last updated