Created
August 14, 2014 22:14
-
-
Save dmlap/6154eec4d7b4e0168c23 to your computer and use it in GitHub Desktop.
Specifying and reading player configuration at runtime.
This file contains hidden or 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
/* | |
* 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. | |
For this plugin, we're going to pass along an account ID that we'll use at runtime: */ | |
"options": { | |
"clientId": 7 | |
} | |
}] | |
} | |
/** | |
* In your plugin code, you'll be passed the options object at initialization. | |
* Here is a very simple plugin that reads the clientId we specified in the player config: | |
*/ | |
var analytics = function(options) { | |
// The setting is available exactly as specified in the player config | |
reportAnalyticsEvent({ | |
clientId: options.clientId | |
}); | |
// You also have access to page-level variables. | |
// Note that a Brightcove player can be embedded in its own iframe or directly into a | |
// publisher's page. Properties like document.referrer may be different depending on how | |
// the player is embedded: | |
reportAnalyticsEvent({ | |
clientId: options.clientId, | |
referrer: document.referrer | |
}); | |
// Media and advertisement info may be present as well. | |
// See https://gist.github.com/dmlap/423d893e2b197d1edce9 for an example of how to access | |
// those properties. | |
}; | |
/* For more info on creating plugins, check out: | |
* - The video.js plugin documentation: https://github.com/videojs/video.js/blob/stable/docs/guides/plugins.md | |
* - The list of open-source video.js plugins: https://github.com/videojs/video.js/wiki/Plugins | |
* - Brightcove's plugin quick-start guide: http://docs.brightcove.com/en/video-cloud/player-management/guides/plugin-dev-quick-start.html | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment