Add MediaEntry to Kaltura in Java using Kaltura Client API
Posted By : Abhimanyu Singh | 04-Mar-2014
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
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.setPartnerId(partnerId);
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.setSessionId((client.getSessionService().start(secret,userId,type,partnerId).toString()));
/* 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 , KalturaMediaType.LIVE_STREAM_QUICKTIME , KalturaMediaType.LIVE_STREAM_REAL_MEDIA
- Add the file type of entry that it will accept
entry.sourceType = KalturaSourceType.FILE;
again KalturaSourceType will be Enum with following possible values KalturaSourceType.FILE,KalturaSourceType.AKAMAI_LIVE,KalturaSourceType.LIMELIGHT_LIVE,KalturaSourceType.WEBCAM,KalturaSourceType.MANUAL_LIVE_STREAM,KalturaSourceType.URL, KalturaSourceType.SEARCH_PROVIDER
- 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);
-
client.getMediaService().add(entry);
it will ad entry to Kaltura
Thanks
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Abhimanyu Singh
Abhimanyu is an seasoned technologist . He always keeps himself ahead in embracing and adapting new technologies/frameworks to solve business problems. He specialise in Blockchain technology , Video Content Management & enterprise software .