Skip to content

Instantly share code, notes, and snippets.

View digitallysavvy's full-sized avatar
:octocat:

Hermes digitallysavvy

:octocat:
View GitHub Profile
@digitallysavvy
digitallysavvy / appListen.js
Created July 16, 2020 18:13
Simple implementation of the Express listen method that passes in the Port and a callback to display the port number.
app.listen(PORT, () => {
console.log(`Listening on port: ${PORT}`);
});
@digitallysavvy
digitallysavvy / nocache.js
Created July 16, 2020 17:58
simple no cache function for use in an express server to force the browser to never cache the response, to ensure fresh response each time.
const nocache = (req, resp, next) => {
resp.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
resp.header('Expires', '-1');
resp.header('Pragma', 'no-cache');
next();
};
@digitallysavvy
digitallysavvy / sendChannelMessage+snippet.js
Last active June 26, 2021 15:52
A snippet for using an creating an Agora RTM message using JSON
function sendChannelMessage(property, direction){
if (localStreams.rtmActive) {
// use a JSON object to send our instructions in a structured way
const jsonMsg = {
property: property,
direction: direction
};
// build the Agora RTM Message
const msg = {
description: undefined,
@digitallysavvy
digitallysavvy / webvr-broadcast-client-base.js
Last active May 16, 2020 01:27
A bare bones implementation of the Agora RTC and RTM Web SDKs for use within the Agora WebXR tutorial.
// Agora settings
const agoraAppId = ''; // insert Agora AppID here
const channelName = 'WebAR';
var streamCount = 0;
// video profile settings
var cameraVideoProfile = '720p_6'; // 960 × 720 @ 30fps & 750kbs
// set log level:
// -- .DEBUG for dev
@digitallysavvy
digitallysavvy / webar-audience-client.js
Last active July 12, 2022 07:53
An implementation of the Agora RTC and RTM Web SDKs for use within the Agora WebXR tutorial.
// create client
var client = AgoraRTC.createClient({mode: 'live', codec: 'vp8'}); // vp8 to work across mobile devices
const agoraAppId = ''; // insert Agora AppID here
const channelName = 'WebAR';
var streamCount = 0;
// set log level:
// -- .DEBUG for dev
@digitallysavvy
digitallysavvy / connectStreamToVideo+snippet.js
Last active May 13, 2020 22:32
A snippet for using an Agora video stream as the source for a video component.
function connectStreamToVideo(agoraStream, video) {
video.srcObject = agoraStream.stream;// add video stream to video element as source
video.onloadedmetadata = () => {
// ready to play video
video.play();
}
}
@digitallysavvy
digitallysavvy / createBroadcaster+snippet.js
Last active May 13, 2020 20:44
A code snippet implementing the createBroadcaster function for Agora WebXR tutorial
function createBroadcaster(streamId) {
// create video element
var video = document.createElement('video');
video.id = "faceVideo-" + streamId;
video.setAttribute('webkit-playsinline', 'webkit-playsinline');
video.setAttribute('playsinline', 'playsinline');
video.setAttribute('poster', '/imgs/no-video.jpg');
console.log(video);
// add video object to the DOM
document.querySelector("a-assets").appendChild(video);
@digitallysavvy
digitallysavvy / style.css
Created May 13, 2020 19:57
CSS styling for the Agora WebXR project.
body {
margin: 0;
padding: 0;
}
body .btn:focus{
outline: none !important;
box-shadow:none !important;
}
@digitallysavvy
digitallysavvy / audience.html
Created May 7, 2020 20:39
A WebAR audience UI using Afame.io, AR.js and Agora.io
<!doctype HTML>
<html>
<head>
<title>Agora AR.js - Live Streamed WebAR</title>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>
<script src="https://rawgit.com/jeromeetienne/AR.js/master/aframe/build/aframe-ar.min.js"></script>
<script src="js/AgoraRTCSDK-3.0.2.js" type="text/javascript"></script>
<script src="js/agora-rtm-sdk-1.2.2.js" type="text/javascript"></script>
@digitallysavvy
digitallysavvy / broadcaster.html
Last active May 7, 2020 20:39
A WebVR broadcaster UI using Afame.io and Agora.io
<html lang="en">
<head>
<title>Agora.io AFrame [HOST] - Live Stream WebVR</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- FontAwesome and Bootstrap CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" rel="stylesheet">
<!-- jQuery and Bootstrap JS -->