0

我为我的视频创建了一个名为 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->createdAt。任何帮助,将不胜感激。

4

2 回答 2

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++;
}
于 2012-11-26T17:53:28.127 回答
1

您应该调用entry.list,然后使用逗号(例如'0_jhb23ad,0_jhbasd3,0_askdja3')将您在结果中收到的条目ID 分解,然后调用metadata.list 传递字段'objectIdIn' 中的条目ID 列表。

顺便说一句,你有一个错误 -

$filter->orderBy = 'CREATED_AT_DESC';

没有影响,应该是

KalturaMediaEntryOrderBy::CREATED_AT_DESC;
于 2012-11-21T16:51:36.483 回答