我已经为我的视频创建了一个名为Record Date的自定义元数据字段,我想知道当我按类别对数据进行排序时如何能够回显这些信息。这是我到目前为止所使用的代码的剪辑。
$pager = new KalturaFilterPager();
$pager->pageIndex = "1";
$pager->pageSize = "200";
if(isset($_REQUEST['category'])){
$category = $_REQUEST['category'];
}
else{
$category = "";
}
$filter = new KalturaMediaEntryFilter();
$filter->categoriesMatchOr = $category;
$filter->orderBy = KalturaMediaEntryOrderBy::CREATED_AT_DESC;
$entries = $client->media->listAction($filter, $pager);
if (!$entries)
{
$entries = array();
}
?>
<ol id="list">
<?php
$count = 0;
foreach ($entries->objects as $entry)
{
echo '<li id="'.$count.'"><img src="'.$entry->thumbnailUrl.'"/> <strong>Name:</strong> '.$entry->name.' <strong>Record Date:</strong> '.date('m/d/Y', $entry->createdAt).' <strong>Duration:</strong> '.$entry->duration.' sec</li>';
$count++;
}
?>
</ol>
我想将$ entry-&gt; createdAt替换为我的自定义元数据字段值。任何帮助,将不胜感激。
答案 0 :(得分:2)
我通过在KalturaMetadataFilter()
语句中应用foreach()
来解决问题。这是代码。
foreach ($entries->objects as $entry){
$filter_meta = new KalturaMetadataFilter();
$filter_meta->metadataObjectTypeEqual = KalturaMetadataObjectType::ENTRY;
$filter_meta->objectIdEqual = $entry->id;
$filter_meta->statusEqual = KalturaMetadataStatus::VALID;
$metadataPlugin = KalturaMetadataClientPlugin::get($client);
$result = $metadataPlugin->metadata->listAction($filter_meta);
//print_r($result);
if(isset($result->objects[0]->xml)){
$xml = simplexml_load_string($result->objects[0]->xml);
$record_date = (int)$xml->RecordDate;
}
else{
$record_date = $entry->createdAt;
}
echo '<li id="'.$count.'"><img src="'.$entry->thumbnailUrl.'"/> <strong>Name:</strong> '.$entry->name.' <strong>Record Date:</strong> '.date('m/d/Y', $record_date).' <strong>Duration:</strong> '.$entry->duration.' sec</li>';
$count++;
}
答案 1 :(得分:1)
你应该调用entry.list,然后用逗号(例如'0_jhb23ad,0_jhbasd3,0_askdja3')破坏你在结果中收到的条目ID,然后调用metadata.list传递字段'objectIdIn'中的条目id列表
是的,你有一个错误 -$filter->orderBy = 'CREATED_AT_DESC';
没有效果,应该是
KalturaMediaEntryOrderBy::CREATED_AT_DESC;