Skip to content

Instantly share code, notes, and snippets.

@dmlap
dmlap / vid-sequence.js
Created December 3, 2014 19:19
Loading videos in a sequence.
var videoIds = [1, 2, 3, 4];
// get the first video
player.catalog.getVideo(videoIds[0], function(error, video) {
if (error) {
return alert(error);
}
videoIds.shift();
// load it into the player so it's ready when the user hits "play"
player.catalog.load(video);
@dmlap
dmlap / button.html
Last active August 29, 2015 14:08
Custom button HTML
<div class="vjs-playback-rate-button vjs-menu-button vjs-control" role="button" aria-live="polite" tabindex="0" aria-haspopup="true" aria-label="Playback Rate Menu">
<div class="vjs-control-content">
<span class="vjs-control-text">1x</span>
<div class="vjs-menu">
<ul class="vjs-menu-content">
<li class="vjs-menu-item" role="button" aria-live="polite" tabindex="0" aria-selected="true">0.5x</li>
<li class="vjs-menu-item vjs-selected" role="button" aria-live="polite" tabindex="0" aria-selected="true">1x</li>
<li class="vjs-menu-item" role="button" aria-live="polite" tabindex="0" aria-selected="true">1.5x</li>
<li class="vjs-menu-item" role="button" aria-live="polite" tabindex="0" aria-selected="true">2.0x</li>
</ul>
@dmlap
dmlap / custom-control.css
Created October 27, 2014 17:31
Specifying button display ordering in the Brightcove player.
/* Specify where your custom control should show up relative to the other buttons.
Buttons are displayed in ascending order, from left to right. The CSS spec only
requires `order` today but you should include the other rules so that your button
is placed correctly on older browsers.
*/
.video-js .vjs-custom-control {
order: 5; /* after the progress bar but before the volume button */
-webkit-box-ordinal-group: 5;
-moz-box-ordinal-group: 5;
-webkit-order: 5;
@dmlap
dmlap / dynamic-vc.html
Last active August 29, 2015 14:07
Loading a Video Cloud video dynamically with an in-page embed.
<!doctype html>
<video
data-account="1234"
data-player="abc-123"
data-embed="default"
class="video-js" controls></video>
<script src="//players.brightcove.net/1234/abc-123_default/index.min.js"></script>
<script>
var player = videojs(document.querySelector('video'));
player.bcCatalog.getVideo('17', function(error, video) {
@dmlap
dmlap / bitrate-switch.html
Created October 2, 2014 18:31
An example of manual bitrate selection with videojs-contrib-hls.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>video.js HLS Plugin Example</title>
<link href="node_modules/video.js/dist/video-js/video-js.css" rel="stylesheet">
<!-- video.js -->
<script src="node_modules/video.js/dist/video-js/video.js"></script>
@dmlap
dmlap / videojs-swf-122-events.md
Last active September 15, 2016 14:12
HTML5 versus Flash event comparision

videojs-swf with #122

Chrome 37

preload="auto"

  • progress
  • loadstart
  • loademetadata
  • loadeddata
  • canplaythrough
  • progress
  • play
@dmlap
dmlap / plugin-options.js
Created September 25, 2014 13:58
A robust Brightcove player plugin will accept all of its necessary configuration as initialization options and fall back on data attributes for defaults.
videojs.plugin('example', function(options) {
var player = this,
defaults,
settings;
// grab default configuration from data attributes
// these will be set automatically by Video Cloud but can be provided by any other video
// CMS as well
defaults = {
// player.options() is automatically populated with any data attributes declared on
@dmlap
dmlap / video-load.js
Created September 22, 2014 13:49
Loading a video into a player.
// change the video source URL
player.src({
src: 'http://example.com/movie.mp4',
type: 'video/mp4'
});
// Safari requires you to call load after loading a new video source
player.load();
@dmlap
dmlap / by-hand-init.html
Created September 19, 2014 20:55
Initializing a plugin by hand. If some of the information required for a plugin's configuration isn't available until the player has loaded in a page, you can delay initializing it until you're ready.
<!doctype html>
<video
data-account="1234"
data-player="5678"
data-embed="default"
class="video-js" controls></video>
<script src="//players.brightcove.net/1234/5678_default/index.min.js"></script>
<script>
var player = videojs(document.querySelector('video'));
@dmlap
dmlap / accountIdGetter.js
Created September 19, 2014 18:23
Accessing the account ID in a player plugin.
videojs('accountIdGetter', function() {
var player = this;
console.log('Account ID', player.el().getAttribute('data-account'));
});