Exemple #1
0
 public function validateEndTime(CuePoint $cuePoint = null)
 {
     if (is_null($this->startTime) && $cuePoint && $cuePoint->getStartTime()) {
         $this->startTime = $cuePoint->getStartTime();
     }
     if (is_null($this->triggeredAt) && $cuePoint && $cuePoint->getTriggeredAt()) {
         $this->triggeredAt = $cuePoint->getTriggeredAt();
     }
     if ($this->startTime) {
         if ($this->isNull('endTime') && (!$cuePoint || is_null($cuePoint->getEndTime()))) {
             $this->endTime = $this->startTime;
         }
         if (!is_null($this->endTime) && $this->endTime < $this->startTime) {
             throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_CANNOT_BE_LESS_THAN_START_TIME, $this->parentId);
         }
     } elseif ($this->triggeredAt) {
         if ($this->isNull('duration') && (!$cuePoint || is_null($cuePoint->getDuration()))) {
             $this->duration = 0;
         }
         if ($this->duration && $this->duration < 0) {
             throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_CANNOT_BE_LESS_THAN_START_TIME, $this->parentId);
         }
     } else {
         if (!$this->isNull('duration') || !$this->isNull('endTime')) {
             throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_WITHOUT_START_TIME);
         }
     }
     if ($cuePoint) {
         $dbEntry = entryPeer::retrieveByPK($cuePoint->getEntryId());
     } else {
         $dbEntry = entryPeer::retrieveByPK($this->entryId);
     }
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->entryId);
     }
     if ($dbEntry->getType() != entryType::LIVE_STREAM && $dbEntry->getLengthInMsecs()) {
         if ($this->endTime && $dbEntry->getLengthInMsecs() < $this->endTime) {
             throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_IS_BIGGER_THAN_ENTRY_END_TIME, $this->endTime, $dbEntry->getLengthInMsecs());
         }
         if ($this->duration && $dbEntry->getLengthInMsecs() < $this->duration) {
             throw new KalturaAPIException(KalturaCuePointErrors::END_TIME_IS_BIGGER_THAN_ENTRY_END_TIME, $this->duration, $dbEntry->getLengthInMsecs());
         }
     }
 }
Exemple #2
0
 protected function reIndexCuePointEntry(CuePoint $cuePoint)
 {
     //index the entry after the cue point was added|deleted
     $entryId = $cuePoint->getEntryId();
     $entry = entryPeer::retrieveByPK($entryId);
     if ($entry) {
         $entry->setUpdatedAt(time());
         $entry->save();
         $entry->indexToSearchIndex();
     }
 }
 /**
  * @param CuePoint $cuePoint
  * @param SimpleXMLElement $scene
  * @return SimpleXMLElement the created scene
  */
 public static function generateCuePointXml(CuePoint $cuePoint, SimpleXMLElement $scene)
 {
     $scene->addAttribute('sceneId', $cuePoint->getId());
     $scene->addAttribute('entryId', $cuePoint->getEntryId());
     if ($cuePoint->getSystemName()) {
         $scene->addAttribute('systemName', kMrssManager::stringToSafeXml($cuePoint->getSystemName()));
     }
     $scene->addChild('sceneStartTime', kXml::integerToTime($cuePoint->getStartTime()));
     if ($cuePoint->getPuserId()) {
         $scene->addChild('userId', kMrssManager::stringToSafeXml($cuePoint->getPuserId()));
     }
     if (trim($cuePoint->getTags(), " \r\n\t")) {
         $tags = $scene->addChild('tags');
         foreach (explode(',', $cuePoint->getTags()) as $tag) {
             $tags->addChild('tag', kMrssManager::stringToSafeXml($tag));
         }
     }
     return $scene;
 }