Skip to content

Instantly share code, notes, and snippets.

@cuhong
Last active August 11, 2020 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuhong/e40283282605bfc424eeb9e132fcee10 to your computer and use it in GitHub Desktop.
Save cuhong/e40283282605bfc424eeb9e132fcee10 to your computer and use it in GitHub Desktop.
<main class="container-fluid d-flex align-items-center"
style="position: absolute; top: 0; bottom: 0; overflow: hidden;">
<div class="row align-items-center" style="height: 100vh;" id="videoContainer">
<div class="col-12 text-center" style="padding: 0">
<video id="remoteVideo" class="remoteVideo" autoplay muted playsinline
style="width: 100vw !important; margin-right: 0; margin-left: 0;"></video>
<video id="tempVideo" hidden></video>
</div>
</div>
</main>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@remotemonster/sdk/remon.min.js"></script>
<script src="https://cdn.WebRTC-Experiment.com/getScreenId.js"></script>
<script>
let channel_Id = '{{ channel_id }}'
const res_x = parseInt(window.innerWidth) * 3;
const res_y = parseInt(window.innerHeight) * 3;
const aspectRatio = res_y / res_x;
const remonConfig = {
credential: {
serviceId: '{{ remonId }}',
key: '{{ remonSecret }}'
},
media: {
recvonly: true
},
view: {
remote: '#remoteVideo'
}
};
function getUrl(action = null) {
var base = window.location.href
var url = `${base}?channelId=${channel_Id}`
if (action) {
url = `${url}&action=${action}`
}
return url
}
const listener = {
onJoin() {
document.getElementById('callWait').hidden = true
document.getElementById('callInitFail').hidden = true
document.getElementById('videoContainer').hidden = false
},
onError(e) {
console.log(e)
},
onStat(result) {
const stat = `State: l.cand: ${result.localCandidate} /r.cand: ${result.remoteCandidate} /l.res: ${result.localFrameWidth} x ${result.localFrameHeight} /r.res: ${result.remoteFrameWidth} ${result.remoteFrameHeight} /l.rate: ${result.localFrameRate} /r.rate: ${result.remoteFrameRate} / Health: ${result.rating}`
console.log(stat)
}
};
const caster = new Remon({listener, config: remonConfig});
caster.joinCast(channel_Id);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment