Skip to content

Instantly share code, notes, and snippets.

View kwindla's full-sized avatar

Kwindla Hultman Kramer kwindla

View GitHub Profile
@kwindla
kwindla / soup-server.js
Created April 25, 2017 22:37
minimal mediasoup server
import cmdLineArgs from 'command-line-args';
import mediasoup from 'mediasoup';
import WebSocket from 'ws';
import {
remove,
find,
sortBy,
reverse,
} from 'lodash';
@kwindla
kwindla / video-hello-world.html
Created January 26, 2019 21:22
Daily.co Embedded Video Call "Hello World"
<html>
<head>
<title>embedded video call</title>
</head>
<body style="background: -webkit-gradient(linear, left top, left bottom,
from(#23cb40), to(#aaaaaa)) fixed;">
<iframe
allow="camera,microphone,display"
src="https://kwindla.daily.co/hello"
height="75%" width="40%"
@kwindla
kwindla / button-and-iframe.js
Created March 10, 2019 21:47
a button that starts a video call
<button onclick="startCall()">
start call
</button>
<script>
async function startCall() {
let callUrl = 'https://api-demo.daily.co/this-is-a-placeholder',
iframeEl = document.createElement('iframe');
iframeEl.width = 350;
iframeEl.height = 425;
@kwindla
kwindla / button-and-iframe.js
Created March 10, 2019 21:49
a button that starts a new video call
<button onclick="startCall()">
start call
</button>
<script>
async function startCall() {
let callUrl = 'https://api-demo.daily.co/this-is-a-placeholder',
iframeEl = document.createElement('iframe');
iframeEl.width = 350;
iframeEl.height = 425;
@kwindla
kwindla / create-room.sh
Last active March 10, 2019 21:52
create a new room (command line)
# create a new video call room, with a random name,
# that expires 60 seconds from now
#
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $YOUR_API_TOKEN" \
-XPOST -d \
'{"properties":{"exp":'`expr $(date +%s) + 60`'}}' \
https://api.daily.co/v1/rooms/
@kwindla
kwindla / iframe-new-room-url.js
Created March 10, 2019 21:54
create a new room and join it
// you can replace this with your own repl.it endpoint URL!
const createRoomEndpoint = 'https://create-a-room--kwindla.repl.co'
async function startCall() {
let response = await fetch(createRoomEndpoint),
roomData = await response.json(),
callUrl = roomData.url;
let iframeEl = document.createElement('iframe');
iframeEl.width = 350;
@kwindla
kwindla / maybe-join-call.js
Created March 10, 2019 21:56
if our page's url includes a hash fragment, treat that as a call url to join on page load
<body onload="maybeJoinCall()">
function maybeJoinCall() {
if (window.location.hash) {
startCall(window.location.hash.substring(1));
}
}
@kwindla
kwindla / start-call-2.js
Created March 10, 2019 21:59
modified startCall() - create a new room only if we aren't passed a callUrl argument
const createRoomEndpoint = 'https://create-a-room--kwindla.repl.co';
async function startCall(callUrl) {
if (!callUrl) {
let response = await fetch(createRoomEndpoint),
roomData = await response.json();
callUrl = roomData.url;
}
let iframeEl = document.createElement('iframe');
@kwindla
kwindla / leave-call.js
Created March 10, 2019 22:00
transform our button into a "leave call" button
let button = document.getElementById('start-call-button');
button.innerHTML = 'end call';
button.onclick = () => {
document.body.removeChild(iframeEl);
iframeEl.src = null;
button.innerHTML = 'start call';
button.onclick = startCall;
// window.location.origin is this page's url
// without the hash fragment
window.location = window.location.origin
style {
.testClass {
background-color: red;
}
}