I'm trying to update field "plays" of a media Entry but while the code runs without any problems/exceptions the value of the entry stays the same.
The code i'm using is below :
try {
String ks = client.getSessionService().start(ADMIN_SECRET, "admin",
KalturaSessionType.ADMIN, PARTNER_ID, 86400, "disableentitlement");
client.setKs(ks);
client.setSessionId(ks);
// Get Media Entry
KalturaMediaEntry getMediaEntry = client.getMediaService().get(entry_id);
// Get plays of Media Entry
int plays = getMediaEntry.plays;
int updatedPlays = plays + 1;
// Create updated Media Entry with plays+1
KalturaMediaEntry updatedMediaEntry = new KalturaMediaEntry();
updatedMediaEntry.plays = updatedPlays;
// Update
client.getMediaService().update(entry_id, updatedMediaEntry);
} catch (KalturaApiException e) {
e.printStackTrace();
Log.i(TAG, "Update Num of plays error: " + e.getMessage() );
}
Anyone can help me with this? Thanks in advance.
KalturaMediaEntry.plays
is not updatable using the API, this is a read-only field.
See https://github.com/kaltura/server/blob/Kajam-11.18.0/api_v3/lib/types/entry/KalturaPlayableEntry.php#L12
The API should actually be throwing an error when trying to update this field.
I assume that you are using a self hosted version of Kaltura, in that case it is possible to update plays using a direct DB script.
You can use https://github.com/kaltura/server/blob/Kajam-11.18.0/alpha/scripts/utils/updateEntryInSphinx.php as an example.
Located at /opt/kaltura/app/alpha/scripts/utils/updateEntryInSphinx.php
Before $sphinx->saveToSphinx($entry, false, true);
add
$entry->setPlays($entry->getPlays() + 1);
$entry->save();
Execute with php /opt/kaltura/app/alpha/scripts/utils/updateEntryInSphinx.php ENTRY_ID execute