Adaptive Streaming has become the neccessity for streaming video and audio. Unfortantely, as of this post, there isn't a whole lot of tutorials that accumulate all of the steps to get this working. Hopefully this post achieves that. This post focuses on using Amazon Web Services (AWS) to transcode for HLS and DASH and be the Content Delivery Network (CDN) that delivers the stream to your web page. We'll be using Video.js for the HTML5 player as well as javascript support libaries to make Video.js work with HLS and DASH.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ObjectOmit } from 'typelevel-ts' | |
const get = <O, K extends keyof O>(k: K, o: O): O[K] => o[k] | |
const set = <O, K extends keyof O>(k: K, v: O[K], o: O): O => Object.assign({}, o, { [k as any]: v }) | |
const remove = <O, K extends keyof O>(k: K, o: O): ObjectOmit<O, K> => { | |
const copy: any = Object.assign({}, o) | |
delete copy[k] | |
return copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logClass(target: any) { | |
// save a reference to the original constructor | |
var original = target; | |
// a utility function to generate instances of a class | |
function construct(constructor, args) { | |
var c : any = function () { | |
return constructor.apply(this, args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLEASE CHECK THIS REPO WITH THE EXAMPLES THAT YOU CAN RUN: | |
https://github.com/apieceofbart/async-testing-with-jest-fake-timers-and-promises | |
// Let's say you have a function that does some async operation inside setTimeout (think of polling for data) | |
function runInterval(callback, interval = 1000) { | |
setInterval(async () => { | |
const results = await Promise.resolve(42) // this might fetch some data from server | |
callback(results) | |
}, interval) |