/** * TODO add doc */ private function generateJobs(MultimediaObject $multimediaObject, $pubChannelCod) { $jobs = array(); foreach ($this->profiles as $targetProfile => $profile) { $targets = $this->getTargets($profile['target']); if (in_array($pubChannelCod, $targets['standard']) && $multimediaObject->isOnlyAudio() == $profile['audio']) { if (!$multimediaObject->isOnlyAudio() && 0 != $profile['resolution_ver']) { $profileAspectRatio = $profile['resolution_hor'] / $profile['resolution_ver']; $multimediaObjectAspectRatio = $multimediaObject->getTrackWithTag("master")->getAspectRatio(); if (1.5 > $profileAspectRatio !== 1.5 > $multimediaObjectAspectRatio) { $this->logger->info(sprintf("JobGeneratorListener can't create a new job (%s) for multimedia object %s using standard target, " . "because a video profile aspect ratio(%f) is diferent to video aspect ratio (%f)", $targetProfile, $multimediaObject->getId(), $profileAspectRatio, $multimediaObjectAspectRatio)); continue; } } $master = $multimediaObject->getTrackWithTag("master"); $this->logger->info(sprintf("JobGeneratorListener creates new job (%s) for multimedia object %s using standard target", $targetProfile, $multimediaObject->getId())); $jobs[] = $this->jobService->addUniqueJob($master->getPath(), $targetProfile, 2, $multimediaObject, $master->getLanguage()); } if (in_array($pubChannelCod, $targets['force'])) { if ($multimediaObject->isOnlyAudio() && !$profile['audio']) { $this->logger->info(sprintf("JobGeneratorListener can't create a new job (%s) for multimedia object %s using forced target, because a video profile can't be created from an audio", $targetProfile, $multimediaObject->getId())); continue; } $master = $multimediaObject->getTrackWithTag("master"); $this->logger->info(sprintf("JobGeneratorListener creates new job (%s) for multimedia object %s using forced target", $targetProfile, $multimediaObject->getId())); $jobs[] = $this->jobService->addUniqueJob($master->getPath(), $targetProfile, 2, $multimediaObject, $master->getLanguage()); } } return $jobs; }
/** * Get default url pic * * Get the default url pic * for a given resource checking if * it is Series, MultimediaObject of type * video or audio * * @param Series|MultimediaObject $object Object to get the url (using $object->getPics()) * @param boolean $absolute Returns absolute path * @param boolean $hd Returns pic in HD * * @return string */ public function getDefaultUrlPicForObject($object, $absolute = false, $hd = true) { if ($object instanceof Series) { return $this->getDefaultSeriesUrlPic($absolute); } elseif ($object instanceof MultimediaObject) { return $this->getDefaultMultimediaObjectUrlPic($absolute, $object->isOnlyAudio(), $hd); } return $this->getDefaultMultimediaObjectUrlPic($absolute, false, $hd); }
private function generatePic(MultimediaObject $multimediaObject, Track $track) { if ($multimediaObject->getPics()->isEmpty() && $this->autoExtractPic) { try { if ($multimediaObject->isOnlyAudio() || $track->isOnlyAudio()) { // TODO: Change return values when adding final default audio image //return $this->addDefaultAudioPic($multimediaObject, $track); return false; } else { return $this->generatePicFromVideo($multimediaObject, $track); } } catch (\Exception $e) { $this->logger->error(__CLASS__ . '[' . __FUNCTION__ . '] ' . 'There was an error in extracting a pic for MultimediaObject "' . $multimediaObject->getId() . '" from Track "' . $track->getId() . '". Error message: ' . $e->getMessage()); return false; } } return false; }
public function testIsOnlyAudio() { $mm = new MultimediaObject(); $t1 = new Track(); $t1->setOnlyAudio(true); $t2 = new Track(); $t2->setOnlyAudio(true); $t3 = new Track(); $t3->setOnlyAudio(true); $t4 = new Track(); $t4->setOnlyAudio(true); $t5 = new Track(); $t5->setOnlyAudio(true); $mm->addTrack($t3); $mm->addTrack($t2); $mm->addTrack($t1); $mm->addTrack($t4); $mm->addTrack($t5); $this->assertTrue($mm->isOnlyAudio()); $t5->setOnlyAudio(false); $this->assertFalse($mm->isOnlyAudio()); }