Skip to content

Instantly share code, notes, and snippets.

View digitallysavvy's full-sized avatar
:octocat:

Hermes digitallysavvy

:octocat:
View GitHub Profile
@digitallysavvy
digitallysavvy / .js
Last active July 19, 2019 21:47
function to add remote stream div
// REMOTE STREAMS UI
function addRemoteStreamMiniView(remoteStream){
var streamId = remoteStream.getId();
// append the remote stream template to #remote-streams
$('#remote-streams').append(
$('<div/>', {'id': streamId + '_container', 'class': 'remote-stream-container col'}).append(
$('<div/>', {'id': streamId + '_mute', 'class': 'mute-overlay'}).append(
$('<i/>', {'class': 'fas fa-microphone-slash'})
),
$('<div/>', {'id': streamId + '_no-video', 'class': 'no-video-overlay text-center'}).append(
@digitallysavvy
digitallysavvy / .js
Last active July 19, 2019 21:47
logic to swap small container with full screen video
var containerId = '#' + streamId + '_container';
$(containerId).dblclick(function() {
// play selected container as full screen - swap out current full screen stream
remoteStreams[mainStreamId].stop(); // stop the main video stream playback
addRemoteStreamMiniView(remoteStreams[mainStreamId]); // send the main video stream to a container
$(containerId).empty().remove(); // remove the stream's miniView container
remoteStreams[streamId].stop() // stop the container's video stream playback
remoteStreams[streamId].play('full-screen-video'); // play the remote stream as the full screen video
mainStreamId = streamId; // set the container stream id as the new main stream id
});
@digitallysavvy
digitallysavvy / .js
Last active July 19, 2019 21:47
function to remove the remote containers
// remove the remote-container when a user leaves the channel
client.on("peer-leave", function(evt) {
var streamId = evt.stream.getId(); // the the stream id
if(remoteStreams[streamId] != undefined) {
remoteStreams[streamId].stop(); // stop playing the feed
delete remoteStreams[streamId]; // remove stream from list
if (streamId == mainStreamId) {
var streamIds = Object.keys(remoteStreams);
var randomId = streamIds[Math.floor(Math.random()*streamIds.length)]; // select from the remaining streams
remoteStreams[randomId].stop(); // stop the stream's existing playback
@digitallysavvy
digitallysavvy / .js
Last active October 30, 2023 22:10
Full implementation of Agora interface
// simple JS interface for Agora.io web SDK
// app / channel settings
var agoraAppId = " "; // Set your Agora App ID
var channelName = 'agora-web-docs-demo';
// video profile settings
var cameraVideoProfile = '480_4'; // 640 × 480 @ 30fps & 750kbs
var screenVideoProfile = '480_2'; // 640 × 480 @ 30fps
public void OnButtonClick()
{
Debug.Log("Button Clicked: " + name);
// determin which button
if (name.CompareTo("JoinButton") == 0)
{
// join chat
OnJoinButtonClicked();
}
private void OnJoinChannelSuccess (string channelName, uint uid, int elapsed)
{
Debug.Log("Successfully joined channel: " + channelName + " with id: " + uid);
}
private void OnUserJoined (uint uid, int elapsed)
{
Debug.Log("New user has joined channel with id: " + uid);
// add remote stream to scene
@digitallysavvy
digitallysavvy / build.gradle
Created March 15, 2019 00:38
Tanks!!! - EveryPlay updated build.gradle
// UNITY EXPORT COMPATIBLE
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
public class EveryplaySettings : ScriptableObject
{
public string clientId;
public string clientSecret;
public string redirectURI = "https://m.everyplay.com/auth";
public bool iosSupportEnabled;
public bool tvosSupportEnabled;
public bool androidSupportEnabled;
public bool standaloneSupportEnabled;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using agora_gaming_rtc;
#if(UNITY_2018_3_OR_NEWER)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using agora_gaming_rtc;
public class LeaveHandler : MonoBehaviour
{
// Start is called before the first frame update
void OnEnable()