Skip to content

Repository files navigation

Kaltura Embed Code Generator

This Javascript library can be used to generate Kaltura Embed Codes.

It was designed to easiliy create embed codes on-the-fly for your projects.

Quick Start

  1. Include KalturaEmbedCodeGenerator.js to your page.

    <scriptsrc="/{path_to_script}/KalturaEmbedCodeGenerator.js"></script>
  2. Create a new instance of the generator, pass in configuration object and call getCode method.

    <textareaid="code"></textarea><script>vargen=newkEmbedCodeGenerator({partnerId: 0000,uiConfId: 999,entryId: '0_xsd34g3'});document.getElementById('code').innerHTML=gen.getCode();</script>

Configuration

OptionDescriptionDefault
embedType stringEmbed code type to generate. Can we one of: 'auto', 'dynamic', 'thumb', 'iframe', 'legacy'"auto"
playerId stringThe player element Id to generate"kaltura_player"
protocol stringEmbed HTTP protocol to use"http"
host stringHost for loading html5 library & kdp swf"www.kaltura.com"
securedHost stringSecured host for loading html5 library & kdp swf"www.kaltura.com"
widgetId stringKaltura Widget Id_{partnerId}
partnerId intKaltura Partner Idnull
cacheSt intAdd cacheSt parameter to bust cache. Should be future timestampnull
uiConfId intKaltura UiConf Idnull
entryId stringKaltura Entry Idnull
entryMeta objectEntry Metadata object. Example: {name: "Foo", description: "Bar", thumbnailUrl: "http://foo.bar.com/img.jpg"}null
width intSet player width400
height intSet player height330
attributes objectAdds additonal attributes to embed code. Example: { "class": "player" }{} (empty object)
flashVars objectAdds flashVars to player. Example: { "autoPlay": "true" }{} (empty object)
includeKalturaLinks booleanInclude Kaltura SEO linkstrue
includeSeoMetadata booleanInclude Entry SEO Metadata ( taken from {entryMeta} option )false
includeHtml5Library booleanInclde HTML5 Library in legacy embed typetrue

You can set the configuration options when creating a new instance to set the defaults and you can also set the configuration when calling getCode method.

Any option that sets on getCode will override options that were set when creating the instance.

vargen=newkEmbedCodeGenerator({'host': 'cdnapi.kaltura.com','partnerId': 1111,'widgetId': 1111,'width': 680,'height': 420});console.log(gen.getCode({'uiConfId': 0000000,'entryId': 'x_0000000','height': 300// Will generate embed with "height" of 300px }));

If you like to play with all the different options you're welcome to try out the demo

Dependencies

This library uses Handlebars to manage the embed code templates and includes handlebars.runtime.js library. If your project already uses handlebars, you can remove that file from grunt.js file.

This library also uses JSON.strinify method which is supported nativaliy in modern browsers. If you need to support older browsers, please add the following code.

<!--[if lt IE 9]><script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script><![endif]-->

Build minified version

Just run:

grunt

About

Kaltura Embed Code generator library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages