Skip to content

Instantly share code, notes, and snippets.

View kwindla's full-sized avatar

Kwindla Hultman Kramer kwindla

View GitHub Profile
@kwindla
kwindla / web-audio-merge.js
Created January 7, 2020 23:56
merge audio tracks partial sample
setupAudioContext () {
this.audioContext = new window.AudioContext();
// create an output stream node. have to use the constructor form
// because we want to make the stream mono
this.audioOut = new MediaStreamAudioDestinationNode(this.audioContext,
{ channelCount: 1 });
// connecting a single gain node to the audioOut node suffices for
// the pipeline to work. a MediaStreamDestination with nothing
@kwindla
kwindla / sample-createCallObject.html
Created December 30, 2019 20:13
Daily.co API for video chat: simple "object-style" sample
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>basic video call object demo</title>
<script src="https://unpkg.com/@daily-co/daily-js"></script>
</head>
<body onload="run()">
<p> <button onclick="callFrame.join()">join call</button> </p>
<p> <button onclick="callFrame.leave()">leave call</button> </p>
@kwindla
kwindla / simple-start-camera.html
Last active October 27, 2021 07:03
Daily.co API for video chat: start camera before joining.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>basic video call object demo</title>
<script crossorigin src="https://unpkg.com/@daily-co/daily-js"></script>
<!-- <script crossorigin src="../dist/daily-iframe.js"></script> -->
</head>
<body onload="run()">
<p> <button onclick="callFrame.startCamera()">start camera</button> </p>
@kwindla
kwindla / checkForFaces()
Created November 5, 2019 03:10
Function to loop forever while in a Daily.co call, drawing bounding boxes around faces
async function checkForFaces() {
try {
if (callFrame.meetingState() !== 'joined-meeting') {
return;
}
// remove all bounding boxes
for (let el of document.getElementsByClassName('face-boxes')) {
el.remove();
}
// detect faces
style {
.testClass {
background-color: red;
}
}
@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
@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 / 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 / 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 / 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/