Skip to content

Instantly share code, notes, and snippets.

View robwalch's full-sized avatar

Rob Walch robwalch

View GitHub Profile
@robwalch
robwalch / jw6-event-delegation.js
Last active August 29, 2015 14:06
JW Player event delegation example
var jw = jwplayer('jwplayer').setup({file:"videofile.mp4"});
var noop = function() {/* do nothing */}
var timeDelegate = noop;
jw.onTime(timeDelegate);
jw.onPlaylistItem(function(itemEvent) {
if (itemEvent.index === 1) {
@robwalch
robwalch / audio-levels.js
Last active January 7, 2016 21:03
Print out audio levels for all video / audio elements on the page
// audio-levels.js
// https://github.com/bgrins/devtools-snippets
// Print out audio levels for all video / audio elements on the page.
// Watch out for: "MediaElementAudioSource outputs zeroes due to CORS access restrictions" ...for x-origin media urls
(function() {
[].forEach.call(document.querySelectorAll("video,audio"), function(media) {
var splitPath = media.src.split('/');
@robwalch
robwalch / tos-4k.sh
Last active July 6, 2020 07:00
Tears of Steal 4k multibitrate multitrack HLS encode
#!/bin/sh
mkdir -p variant_source
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v baseline -s 480x212 -aspect 9/4 -acodec aac -strict experimental -ac 2 -b:a 96k -ar 44100 -bufsize 360K -maxrate 360K variant_source/ld.mp4
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v main -s 640x288 -aspect 9/4 -an -bufsize 720K -maxrate 720K variant_source/sd.mp4
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 1280x572 -aspect 9/4 -an -bufsize 2400K -maxrate 2400K variant_source/hd.mp4
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 1920x856 -aspect 9/4 -an -bufsize 3200K -maxrate 3200K variant_source/fullhd.mp4
ffmpeg -y -i tearsofsteel_4k.mov -vcodec libx264 -preset veryfast -crf 18 -profile:v high -s 2560x1142 -aspect 9/4 -an -bufsize 4800K -maxrate 4800K variant_source/quadhd.mp4
var RollingSpider = require('rolling-spider');
//discover.js
var drone = new RollingSpider({
// uuid: ['RS_W179234'],
logger: console.log
// forceConnect: true
});
console.log('drone', drone);
/*
This script extends jwplayer api instances with a `_history`
property which is a hash of event types including "all".
After including this on the page, to check if a "play" event fired,
call `jwplayer()._history.play`. Initially this returns `undefined`.
Once the event is fired an array is populated with an object for each
event fired.
The `jwplayer()._history.all` array will always be present and contains
@robwalch
robwalch / index.html
Created December 8, 2015 01:31 — forked from anonymous/index.html
Buffering // source http://jsbin.com/wokoraz
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Buffering</title>
<style>
.ranges {
height: 20px;
position: relative;
width: 400px;
@robwalch
robwalch / media-element-observer.js
Last active March 29, 2021 19:03
Observe attribute changes, method calls and events fired on a media element
const mediaElement = document.createElement('video');
function toString(video) {
return ((video.parentNode ? ('<' + video.parentNode.nodeName + '>') : '') + '<' + video.nodeName + '>')
.toLowerCase();
}
function videoEventHandler(e) {
console.warn(toString(e.target) + ' >> "' + e.type + '"');
}
@robwalch
robwalch / jwplayer.timer.js
Created June 14, 2018 13:54
Sample customer provider for jwplayer
(function(jwplayer) {
var utils = jwplayer.utils;
var _ = jwplayer._;
var TIMEOUT_MS = 25;
var TIMEOUT_SEC = TIMEOUT_MS/1000;
var TIMER = 'timer';
function formatTime(t) {
t *= 1000; // seconds to milliseconds
@robwalch
robwalch / jwplayer-event-listeners.js
Last active July 2, 2018 01:48
Use Chrome's `getEventListeners` to list all even listeners added on the player container and child elements.
(function(jwplayer) {
const container = jwplayer().getContainer();
const elements = Array.prototype.slice.call(container.querySelectorAll('*'))
.filter(element => element.tagName !== 'path');
elements.unshift(container);
const listeners = elements.reduce((accumulator, element) => {
const listenersObj = getEventListeners(element);
return accumulator.concat(Object.keys(listenersObj).reduce((accumulator2, name) => {
listenersObj[name].forEach(eventListener => {
@robwalch
robwalch / media-element-observer-iife.js
Last active November 13, 2019 20:34
Observe attribute changes, method calls and events fired on a media element
(function (video) {
function toString() {
return ((video.parentNode ? ('<' + video.parentNode.nodeName + '>') : '') + '<' + video.nodeName + '>')
.toLowerCase();
}
function videoEventHandler(e) {
console.warn(toString() + ' >> "' + e.type + '"');
}
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
if (MutationObserver) {