kudos!

This is the official project page for the kudos-js Brightcove Javascript SDK.

kudos is designed to be a simple wrapper class for the Brightcove Media API. It exposes all of the native Brightcove read methods. Below, you'll find a breakdown of the included methods and properties, as well as some examples of use.

The kudos project is not officially supported by Brightcove but is written by Brian Franklin and Matthew Congrove, two engineers from the Professional Services department of Brightcove. For questions or bug reports, please make use of our Google Group.

If you're looking for a PHP SDK for Brightcove, please check out Echove.

kudos methods

kudos.get()

Description: The get() method is the meat n' bones of the kudos object. It makes API calls through the inject() method, using user-defined parameters. It should be noted that the second argument can be given as a selector value (such as kudos.get("find_video_by_id", 123456789);) but by default, the resulting API call will return through flush(), which won't do anything with it. This ability is present in case a user feels like overriding the default return in the kudos Javascript file.

Arguments: command (string) A Brightcove API method (as listed to the right).
parameters (mixed) Either an object containing the API parameters to apply to the given command, or a single value which is applied to the command's default selector (as listed to the right).

Returns: Due to the nature of the API call, true is returned while the given callback is passed the API call's result.

kudos.inject()

Description: The inject() method simply takes a query string, appends it to the Brightcove API URL, and injects a script tag into the DOM. This includes the API result, bypassing any cross-domain problems experienced by other asynchronous requests.

Arguments: query (string) A query string with no leading question mark. ie; param=val¶m2=val2

Returns: true

kudos.flush()

Description: The flush() method is the default callback function used when one isn't specified by the user. It simply returns without operating on the API response. This functionality is present to prevent errors on pages due to return object insertion without a defined callback.

Arguments: Nothing.

Returns: true

kudos properties

kudos.token

Description: This is the Brightcove Media API read token associated with your account. A token is required to use the Brightcove API. The token value of the kudos object can be set one of three ways. The first is to hardcode the value into the kudos Javascript file. The second option is to declare it in your page's Javascript (kudos.token = "token.goes.here";). The third option is to specify it during an API call with the get() method, putting a token into the params argument (kudos.get("find_all_videos", {"callback":"test", "token":"token.goes.here"});).

kudos.cb

Description: This is where you can specify the default callback function for when none is provided via get() parameter. By default, this value is "kudos.flush", but you can set it to any function or method name you'd like to use as a handler. It should be noted that the callback function you define should expect one argument, which is the Brightcove API return object.

project links

Google Code

Download kudos

Download kudos bcss

API Playground

BCSS Loader Example

Google Group

supported methods

shorthand is fun

The kudos object supports the use of shorthand for API methods. For instance "find_video_by_id" can be written "video_by_id" or even "videoById". This can help make code more readable, eliminating the awkward get/find combination.

using kudos


<script src="kudos-0.1.js" type="text/javascript"></script>

<script type="text/javascript">

	// Simply make a call to the API requesting content.
	// Note that a callback function is needed to handle the returned data.
	kudos.get("find_all_videos", {"callback":"handle"});
	
	// Our callback loops through the returned videos, alerting their names.
	function handle (response) {
		for (var video in response.items) {
			alert(video.name);
		}
	}

</script>

				

advanced examples


<script src="kudos-0.1.js" type="text/javascript"></script>

<script type="text/javascript">

	// Set the default token and handler for calls
	kudos.token = "token.goes.here";
	kudos.cb = "myclass.method";

	// Our call response will now be sent to myclass.method
	kudos.get("find_all_videos");
	
	// With a token and callback function set, we can use get()'s params as a selector
	kudos.get("find_video_by_id", 1234567890);

</script>