Implementing Kaltura Filters for Media Listing

Posted By : Abhimanyu Singh | 04-Mar-2014

Hi , In this blog I will show you how you Query Kaltura and get Media Listinf based on different condition.

Create a Kaltura Session

You need to get Admin Secret Id , Partner Id , User Id for generating Kaltura Session Id

  1. Go to Settings in Kaltura Management Console
  2. 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.setPartnerId(partnerId);

     config.setEndpoint(serviceUrl); //service url is url of server on which Kaltura is hosted

Create Kaltura Client Object

     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 Next Step is to create KalturaFilter Object

  • KalturaMediaEntryFilter filter = new KalturaMediaEntryFilter();

Now add conditions to this KalturaMediaEntryFilter filter object

 

Some example of filters are

  • filter.orderby = -plays

                 It will used to list MediaEntry in decending order of plays

                other options that you could use here is

                 -createdAt : listing using descending order by date created of Media Entry

                -startDate = listing using descending order by start date of Media Entry

  • filter.categoriesMatchAnd = “category name”

                 To filter Media Entry based on category defined in the Kaltura

  • Now you need to define pager for the Video . pager property define the number of videos you want to fetch . A page could contain maximum 500 videos . Defined by pageSize property and page property defined the number videos you want to fetch .

                        KalturaFilterPager(); pager = new KalturaFilterPager();

                        pager.pageSize = 500;

                        pager.pageIndex = 2 ;

  • Now this step is to list Media Entry

    client.getMediaService().list(filter,pager)

    it will fetch 500 videos from second page

you are done with listing the videos

Thanks Abhimanyu

About Author

Author Image
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 .

Request for Proposal

Name is required

Comment is required

Sending message..