Skip to content

Instantly share code, notes, and snippets.

Valid HTML4 Transitional Doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Valid HTML5 Doctype:
<!DOCTYPE html>
@MaxPower15
MaxPower15 / gist:4019868
Last active January 27, 2016 00:27
Conditional A/B testing with Wistia's API embed
<!--
Steps to do A/B testing.
1. Pick any number of videos in your Wistia account. If they're in the same project, you can compare them in the Project View.
2. Get the hashed ID for each of them (this is the alphanumeric code after /medias/ in the URL bar).
3. Go into the Embed Builder for one of the videos, and grab an API embed code.
4. Change the id attribute in the API embed code to something legible. I renamed it to "thumbnail_test" below.
5. Add a `container` option to the embed code and specify your ID.
5. Modify the embed code to use a different hashed ID based on whatever conditions you want.
The code below chooses one hashed ID if they've come from an email (wemail is in the URL), and one of two others if not.
@MaxPower15
MaxPower15 / gist:3750671
Created September 19, 2012 16:39
Turnstile example starting at nth video in playlist
<div id="wistia_1d35830d05" class="wistia_embed" style="width:947px;height:360px;" data-video-width="640" data-video-height="360">&nbsp;</div>
<script charset="ISO-8859-1" src="http://fast.wistia.com/static/concat/E-v1%2Cplaylist-v1%2Cplaylist-v1-bento%2CrequireEmail-v1.js"></script>
<script>
wistiaPlaylist = Wistia.playlist("1d35830d05", {
version: "v1",
theme: "bento",
videoOptions: {
autoPlay: true,
videoWidth: 640,
videoHeight: 360
@MaxPower15
MaxPower15 / gist:3702165
Created September 11, 2012 21:20
Code to preserve time and play/pause state when switching tabs
var lastT = 0;
var downT = 0;
var lastState = "unknown";
wistiaEmbed.bind("timechange", function(t) {
lastT = t;
});
wistiaEmbed.bind("down", function() {
@MaxPower15
MaxPower15 / ready-mixin.coffee
Created August 28, 2012 22:34
The "ready" pattern in coffeescript, distilled
#
# myObject = new MyObject();
# myObject.ready = readyMixin;
# myObject.asyncInit(function(){ myObject.ready(true); });
#
# myObject.ready(function() {
# console.log("I'm ready now!");
# });
#
# myObject.ready(function() {
@MaxPower15
MaxPower15 / gist:3296228
Created August 8, 2012 16:05
Example embed code for badger playlist theme
<link href="badger.css" rel="stylesheet" />
<div id="wistia_7f5152eb33" class="wistia_embed" style="width:640px;height:661px;" data-video-width="640" data-video-height="480">
If you continue to see this message the videos for your course are not
uploaded yet. Videos should be present 24 hours after the end of the
Review; if you are still inside this window please bear with us while we
convert and upload your videos. If you are seeing this message outside of
the 24 hour mark please call our front desk at 352-505-1320 or post on our
facebook fan page.
</div>
<script charset="ISO-8859-1" src="http://fast.wistia.com/static/concat/E-v1%2Cplaylist-v1%2Cplaylist-v1-bento.js"></script>
@MaxPower15
MaxPower15 / new-badger-css.css
Created August 8, 2012 15:59
CSS for Tutoring Zone's badger playlist theme
.wistia_bento_section_names li {
border-top-right-radius: 5px 5px !important;
border-top-left-radius: 5px 5px !important;
-moz-border-top-right-radius: 5px 5px !important;
-moz-border-top-left-radius: 5px 5px !important;
margin-left: 0 !important;
margin-right: 10px !important;
}
.wistia_bento_section_names a {
font-family: georgia, palatino, "Palatino Linotype", serif !important;
@MaxPower15
MaxPower15 / gist:3093919
Created July 11, 2012 21:59
Abuse of ternary operators in coffeescript
result = Wistia.detect.browser.quirks ? parseInt(elem.offsetHeight, 10) : window.getComputedStyle && getComputedStyle(elem, null) ? parseInt(getComputedStyle(elem, null).height, 10) : elem.currentStyle ? elem.offsetHeight : -1;
@MaxPower15
MaxPower15 / gist:2694471
Created May 14, 2012 15:04
Simple pre-roll
<div id="video_container" class="wistia_embed" style="width:640px;height:272px;" data-video-width="640" data-video-height="272"> </div>
<script charset="ISO-8859-1" src="http://fast.wistia.com/static/E-v1.js"></script>
<script>/*<![CDATA[*/
preRollEmbed = Wistia.embed("d90b54e175", {
version: "v1",
videoWidth: "640",
videoHeight: "272",
@MaxPower15
MaxPower15 / gist:2408358
Created April 17, 2012 19:13
Untested method to get percentWatched
var lastTime = 0,
watchedSecondHash = new Array(Math.floor(wistiaEmbed.duration()));
wistiaEmbed.bind("timechange", function(t) {
var totalSecondsWatched = 0, percentWatched;
watchedSecondHash[Math.floor(t)] = true;
for(var i=0; i < watchedSecondHash.length; i++) {
if (watchedSecondHash[i]) {
totalSecondsWatched++;
}
}