Note: This guide is using an older client library. Developers are advised to always update their client libraries from: http://www.kaltura.com/api_v3/testme/client-libs.php
Overview of basic integration
This guide will show you how to pre-populate your editor clip library.
This guide will use the Kaltura testme API console to demonstrate the API calls in images and code samples will be provided in PHP. This guide is especially useful for publishers creating remixing campaigns.
Note : If you are using the editor but not the remix site there is one important thing you need to know. You do NOT need to create a new mix every time you launch the editor. See bottom of page for more information.
Populate the Editor with Multiple Files (using a script and the KMC)
Select your content in the Kaltura Management Console (KMC)
In order to select the content you want to populate your editor with, follow these few easy steps -
- Log in to the Kaltura Management Console (http://www.kaltura.com/index.php/kmc/kmc) with your username and password.
- Select the videos, images or sound you want to populate your editor with using the check-boxes.
- Click on the 'Add Admin Tags' button at the bottom of the screen. Choose any filter such as 'for_remix'. This filter will determine which entries will be added to your mix.
Defining Parameters
First you need to define a few mandatory paremeters such as your partner id, sub partner id, Kaltura secret etc. You will also need to define the name of the mix you will create (note it will appear as the editor title by default) and the filter for the entries you set as the admin tags in the KMC in the previous step.
It is also recommended you include the Kaltura client at this point:
$userId = "username";
$partnerId = "XXXX";
$subPartnerId = "XXXXXX";
$secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$adminsecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$host = "www.kaltura.com";
$mix_name = "Mix Title";
$filtered_entries = "the_admin_tag_you_set_in_the_kmc";
Start an admin session
The first thing we'll do is to pull the list of entries you determined on earlier in the KMC using the admin tags. Before we call listEntries on your partner we will need an admin session as listEntries is an admin API call:
$config->serviceUrl = $host;
$client = new KalturaClient($config);
$user = new KalturaSessionUser();
$user->userId = $userId;
$result = $client->startSession($user, $adminsecret, true, "edit:*");
$sessionId = @$result["result"]["ks"];
$client->setKS($sessionId);
Build the filter and list the entries
Now that we have the admin session we're able to list the entries we want to add to the mix. We can list and add all of the entries in our partner but since we probably only want a few selected entries, the filter we create will only return entries with the admin tag we defined in the KMC:
$filter = new KalturaEntryFilter();
// .... that are admin-tagged for this purpose (i.e. for the remix)
$filter->multiLikeAndAdminTags = $filtered_entries;
// list entries that are returned with the filter defined above
$result = $client->listEntries($user, $filter, false, null, $pageSize, $page);
$entries = $result['result']['entries'];
Start a web services (normal) session
Now we're going to perform two actions that require a web services (normal) session - create a new mix entry (roughcut) and add the entries we listed above to that mix. Both addRoughcutEntry and addEntry require a web services session:
$sessionId = @$result["result"]["ks"];
$client->setKs($sessionId);
Create a new mix (Roughcut)
Now that we have the session we can create a new mix (roughcut). We'll start by defining the Kaltura entry (only mandatory parameter in this class is the title, in the addRoughcutEntry call itself you pass the entry id, '-2' as the kshow id (fixed parameter - don't ask why). This call will return your new mix ID. You will use it in your minisite so write it down somewhere.
$mix->name = $mix_name;
$result = $client->addRoughcutEntry($user, -2, $mix);
$mix_id = @$result["result"]["entry"]["id"];
echo '<b>Your new mix ID is </b>"' . $mix_id . '"<br>';
Add the entries to the new mix
Now all you need to do is to add the entries you listed above to the mix you just created. Here's some additional documentation that discusses all of the possible KalturaEntry members.
foreach ($entries as $key => $entry) {
$e = new KalturaEntry;
$e->name = $entry["name"];
$e->source = 23;
$e->mediaId = $entry["id"];
$result = $client->addEntry($user, 'entry-' . $mix_id, $e, null, '0');
echo $entry["id"] . '-' . $entry["name"] . '<br>';
}
At this point it's important to make a few clarifications -
- The entries you add will actually be duplicated and form new entries. It's not optimal however that's this specific script's side effect. This also means that every time you run the script you'll double the entries that will be added to the mix since the admin tag is also copied with the entry. I've already received suggestions on better ways to accomplish this use case and avoid this issue and I will add it to this guide soon. If you already figured it out please post your suggestions in the comments.
Obviously you can delete the original files afterwards - you don't need to keep it twice. - The kshow parameter is mandatory in the addEntry, and in this case and in many other cases in this remix site the kshow id will be 'entry-MIX_ID' so if the mix id you created is 'abc123' your kshow will be 'entry-abc123'
- To prevent the entries from being added to the editor timeline (to create a clean start for your users) you will have to pass a parameter called 'quick_edit' false (0) when performing the addEntry call. your client might not have this parameter included so I recommend downloading the code below.
Click here to download the complete script (includes the Kaltura PHP5 Client Library).
*Kalturian* Please review the code, repack and put somewhere public :-) Note it needs to come with the attached client as I made some modifications to the client that are not supported in the generic client.
That's it!
Now editor your remix site configuration file and look for the 'BASE KSHOW' parameter. Your 'BASE KSHOW' will be 'entry-MIX_ID' so if the mix id you created is 'abc123' it should be 'entry-abc123'
Note if you are not using the remix mini site source code and building something of your own you should know that you should NOT open the editor with the mix ID you just created since you probably want to keep it nice and clean. And so before launching the editor you should use the cloneRoughcut API call to create a new mix for that specific user/remixing session and launch the editor with that.
Populate the Editor with a Single or a Few Files (using Testme) - Visual Guide
Start a web services session
First start a web services session. You will need a few mandatory paremeters such as your partner id, sub partner id and Kaltura secret.
Create a new mix (Roughcut)
Now call the ‘addRoughcutEntry’ method in order to create your new empty mix. Once an empty mix has been created you will use it as your template/base mix. Please note -
- The kshow_id should be ‘-2’ in this use case (it is really not important why).
- This call will return your new mix ID. You will use it in your minisite so write it down somewhere.
Add entries to the new mix
Perform “Add Entry” -By passing kshow_id as “entry-{ENTRYID}” when ENTRYID is the id of the template mix you created at the previous step, you basically populate your mix. Passing quick_edit ‘0’ gets the entry added to the clip library, but not to the timeline This step should be repeated for each video that you want to add to the clip library
That's it!
Now editor your remix site configuration file and look for the 'BASE KSHOW' parameter. Your 'BASE KSHOW' will be 'entry-MIX_ID' so if the mix id you created is 'abc123' it should be 'entry-abc123'
Note if you are not using the remix mini site source code and building something of your own you should know that you should NOT open the editor with the mix ID you just created since you probably want to keep it nice and clean. And so before launching the editor you should use the cloneRoughcut API call to create a new mix for that specific user/remixing session and launch the editor with that.
Using the editor but not the remix site?
If you are using the editor but not the remix site there is one important thing you need to know. You do NOT need to create a new mix every time you launch the editor. You only go thorough the process above ONCE to create the base mix, and then CLONE it every time before you launch the editor so each user remixes a clone of the original mix and doesn't manipulate the original clip library.
It is not mentioned in the guide as Kaltura Remix Site already does the cloning for you while you only provide the base mix id. Cloning a roughcut is very easy -
$result = $client->cloneRoughcut($user,$mix_id); // Cloning the mix.
$new_mix_id = @$result["result"]["entry"]["id"]; // Retrieving the new mix id. THIS is what you launch the editor with.
Subscribe to this page
The master checkboxes on the left turn the given subscription on or off. Depending on the setup of the site, you may have additional options for active subscriptions.



