Skip to content

Instantly share code, notes, and snippets.

@dmlap
dmlap / runtime-config.js
Created August 14, 2014 22:14
Specifying and reading player configuration at runtime.
/*
* Publishers (and the Brightcove Studio) can specify options through the player config.
* Here's an example player config:
*/
var config = {
"scripts": ["http://example.com/analytics.js"],
"plugins": [{
"name": "analytics",
/* You can pass arbitrary key-value pairs to a plugin through the options object.
@dmlap
dmlap / gist:778a97aa82ca5faebe64
Created July 29, 2014 19:10
Add a plugin to a Brightcove player from within the page.
<link href="//players.brightcove.net/2335723943001/7b1f9e8e-a538-4792-8147-f4c69d3972b2_default/bc.min.css" rel="stylesheet">
<link href="//players.brightcove.net/videojs-ima3/videojs.ima3.min.css" rel="stylesheet">
<video
id="video"
data-account="2335723943001"
data-player="7b1f9e8e-a538-4792-8147-f4c69d3972b2"
data-embed="default"
data-id="1234"
class="video-js" controls></video>
<script src="//players.brightcove.net/2335723943001/7b1f9e8e-a538-4792-8147-f4c69d3972b2_default/node_modules/video.js/dist/video-js/video.js"></script>
<div class="bc-wrap" style="opacity: 0;" "="" id="W5M0MpCehiHzreSzNTczkc9d" ?=""> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.134777, 2010/02/12-17:32:00 "> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:description rdf:about="" xmlns:xmpmm="http://ns.adobe.com/xap/1.0/mm/" xmlns:stref="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmpmm:originaldocumentid="xmp.did:52A9086EB5FEE011A12194602BCD607E" xmpmm:documentid="xmp.did:14F85C4E003D11E1860DEAD87B68E4F6" xmpmm:instanceid="xmp.iid:14F85C4D003D11E1860DEAD87B68E4F6" xmp:creatortool="Adobe Photoshop CS5 Windows"> <xmpmm:derivedfrom stref:instanceid="xmp.iid:53A9086EB5FEE011A12194602BCD607E" stref:documentid="xmp.did:52A9086EB5FEE011A12194602BCD607E"> </xmpmm:derivedfrom></rdf:description> </rdf:rdf> </x:xmpmeta> <!--?xpacket end="r"?-->��Adobed����
 
  
@dmlap
dmlap / gist:0336e5de308c6a2e1b69
Last active August 29, 2015 14:04
mp2t packet format

Packet Header

0 1 2 3
sb tei pusi tp pid:5 pid tsc afc cc
afl? ...?

PAT

0 1 2 3
pf? ...?
@dmlap
dmlap / localized-player-config.js
Last active August 29, 2015 14:03
Localization and the Player Management APIs
/* First option: make localization an "opportunity" for every plugin */
{
"errors": {
"localizations": {
"es": {
"1": {
"headline": "Espanol!",
"message": "Cual es tu numero de telefono?"
}
}
@dmlap
dmlap / smartplayer-bootstrap.js
Created June 19, 2014 14:57
Psuedo-code for a SmartPlayer plugin that dynamically loads another script based on information supplied by the player at runtime.
(function(window) {
'use strict';
/* Collect the runtime parameters we need. In this case, we parse them out of the fragment identifier. */
var params = window.location.hash.substring(1); // drop the '#'
/* jQuery is available for Smart Player plugins so we can use it to load our primary plugin with the parameters we just gathered */
$.getScript('https://example.com/plugins/plugin.js?' + params, function() {
console.log('Finished loading the main plugin');
});
@dmlap
dmlap / video-metadata.js
Last active August 29, 2015 14:01
Query the player for video metadata.
/* Before player load, very basic video metadata is serialized as JSON to a data attribute:
<video
data-account="2549849259001"
data-player="d9f2b281-6199-4f8b-821d-ecea1504071f"
data-embed="default"
data-video-id="7"
class="video-js" controls></video>
You can access any metadata specified this way by querying the DOM:
@dmlap
dmlap / update.sh
Last active August 29, 2015 14:00
Get rid of default plugins for a player.
curl \
--header "Content-Type: application/json" \
--user $EMAIL \
--request POST \
--data '{
"name": "MySamplePlayer",
"configuration": {
"media": {
"sources": [{
"src":"http://solutions.brightcove.com/bcls/assets/videos/Tiger.mp4",
@dmlap
dmlap / config.js
Last active August 29, 2015 14:00
An example player configuration that allows for custom plugin initialization.
/**
* The player configuration:
*/
{
/* include plugins through the `scripts` property... */
"scripts": [
'http://www.londonlive.co.uk/player/plugins/share-panel.js',
'http://www.londonlive.co.uk/player/plugins/age-gate.js',
'http://www.londonlive.co.uk/player/plugins/poster.js',
'http://www.londonlive.co.uk/player/plugins/logo-badge.js',
@dmlap
dmlap / gist:11382923
Created April 28, 2014 20:22
thumbnail left offset calculation
|--------- page ---------|
| |---- progress ------|
| * mouse |
| |---| left offset |