[HOW TO] Create a new Media Entry in Kaltura using Java programs

Hi , In this blog I will show you how you could create a new Media Entry in Kaltura using Java programs .

Create a Kaltura Session
You need to get Admin Secret Id , Partner Id , User Id for generating Kaltura Session Id
Go to Settings in Kaltura Management Console Click on Integration Setting
you will get the Secret Id , User Id and partner Id

Here is the Java Program code to generate the Kaltura Session Id

String secret = “**********************” ; // Secret Id 
String userId = “**********************”; //add user id 
KalturaSessionType type = KalturaSessionType.ADMIN;  

/* It is enum defined in kaltura api . It could if either KalturaSessionType.USER or KalturaSessionType.ADMIN */
int partnerId = 100;
int expiry = 0;

        Now do the configuration setting in Kaltura      
KalturaConfiguration config = new KalturaConfiguration(); 
config.setEndpoint(serviceUrl); //service url is url of server on which Kaltura is hosted 
KalturaClient client = new KalturaClient(config);  //Create new kaltura client type 


/* client.getSessionService().start(secret, userId, type, partnerId, expiry, privileges);
This line starts a Kaltura session for the client

Now session is created and set for client . Next step is to create Media Entry

Create a KalturaMediaEntry Object
KalturaMediaEntry entry = new KalturaMediaEntry();
Give name to media entry
entry.name = mediaName;
Give Description for your media entry
entry.description = description;
Add userId to media entry
entry.userId = userId;
Give name to media entry
entry.durationType = KalturaDurationType.SHORT;
It could be KalturaDurationType.SHORT , KalturaDurationType.Medium ,
KalturaDurationType.LONG , KalturaDurationType.NOT_AVAILABLE
Add Tag to media entry
entry.tags = tags;

It is string with comma separated value

add adminTags
entry.adminTags = adminTags;

It is string with comma separated value
Categories you media entry
entry.categories = “news , book”;

It is again comma separated string
Add start date for media entry when media will available for play
entry.startDate = Integer.parseInt(startDate);

Add end date for media entry when media will expire and not available for play
entry.endDate = Integer.parseInt(endDate);

Add flavor params Id to which you want to convert the video if added to this entry
entry.flavorParamsIds =flavorParamsIds;

it will be string “2,4,5” where 2, 4 and 5 are Ids of flavor
Add the Media Type
entry.mediaType = KalturaMediaType.VIDEO;

KalturaMediaType is enum and it could be
KalturaMediaType.VIDEO ,KalturaMediaType.IMAGE ,
KalturaMediaType.LIVE_STREAM_FLASH ,
Add the file type of entry that it will accept
entry.sourceType = KalturaSourceType.FILE;

again KalturaSourceType will be Enum with following possible values
Add refrenceId to your Media Entry
entry.referenceId = referenceId;

Add accessControlId to your Media Entry . It is Id of access control define to which reason video will available
entry.accessControlId = Integer.parseInt(accessControlId);


it will ad entry to Kaltura

Source : http: //www.oodlestechnologies.com