public function testNumberMultimediaObjects()
 {
     $privateBroadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_PRI);
     $publicBroadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_PUB);
     $corporativeBroadcast = $this->createBroadcast(Broadcast::BROADCAST_TYPE_COR);
     $mm1 = new MultimediaObject();
     $mm2 = new MultimediaObject();
     $mm3 = new MultimediaObject();
     $mm4 = new MultimediaObject();
     $mm5 = new MultimediaObject();
     $mm1->setStatus(MultimediaObject::STATUS_PROTOTYPE);
     $mm2->setStatus(MultimediaObject::STATUS_BLOQ);
     $mm3->setStatus(MultimediaObject::STATUS_PUBLISHED);
     $mm4->setStatus(MultimediaObject::STATUS_PUBLISHED);
     $mm5->setStatus(MultimediaObject::STATUS_HIDE);
     $mm1->setBroadcast($privateBroadcast);
     $mm2->setBroadcast($privateBroadcast);
     $mm3->setBroadcast($publicBroadcast);
     $mm4->setBroadcast($corporativeBroadcast);
     $mm5->setBroadcast($privateBroadcast);
     $this->assertEquals(2, $privateBroadcast->getNumberMultimediaObjects());
     $this->assertEquals(1, $publicBroadcast->getNumberMultimediaObjects());
     $this->assertEquals(1, $corporativeBroadcast->getNumberMultimediaObjects());
     $publicBroadcast->setNumberMultimediaObjects(3);
     $this->assertEquals(3, $publicBroadcast->getNumberMultimediaObjects());
     $privateBroadcast->setNumberMultimediaObjects(3);
     $privateBroadcast->decreaseNumberMultimediaObjects();
     $this->assertEquals(2, $privateBroadcast->getNumberMultimediaObjects());
 }
 /**
  * Utilizando la libreria ffmpeg_php se genera un Pic que se asocia con el objeto
  * multimedia al que pertenece el archivo.
  *
  * @param MultimediaObject $multimediaObject
  * @param Track $track
  * @param integer $frame numero del frame donde se realiza la captura.
  * @return PIC o null si mal
  */
 private function createPic(MultimediaObject $multimediaObject, Track $track, $frame = 25)
 {
     $currentDir = 'series/' . $multimediaObject->getSeries()->getId() . '/video/' . $multimediaObject->getId();
     $absCurrentDir = $this->targetPath . "/" . $currentDir;
     $picFileName = date('ymdGis') . '.jpg';
     $aux = null;
     @mkdir($absCurrentDir, 0777, true);
     $aspectTrack = $this->getAspect($track);
     if (0 !== $aspectTrack) {
         $newHeight = intval(1.0 * $this->width / $aspectTrack);
         if ($newHeight <= $this->height) {
             $newWidth = $this->width;
         } else {
             $newHeight = $this->height;
             $newWidth = intval(1.0 * $this->height * $aspectTrack);
         }
     } else {
         $newHeight = $this->height;
         $newWidth = $this->width;
     }
     $vars = array("{{ss}}" => intval($frame / 25), "{{size}}" => $newWidth . "x" . $newHeight, "{{input}}" => $track->getPath(), "{{output}}" => $absCurrentDir . '/' . $picFileName);
     $commandLine = str_replace(array_keys($vars), array_values($vars), $this->command);
     $process = new Process($commandLine);
     $process->setTimeout(60);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     //log $process->getOutput()
     if (file_exists($absCurrentDir . '/' . $picFileName)) {
         $multimediaObject = $this->mmsPicService->addPicUrl($multimediaObject, $this->targetUrl . '/' . $currentDir . '/' . $picFileName);
     }
     return true;
 }
示例#3
0
 /**
  * Remove Tag from Multimedia Object
  *
  * @param MultimediaObject $mmobj
  * @param string $tagId
  * @param  boolean          $executeFlush
  * @return Array[Tag] removed tags
  */
 public function removeTagFromMultimediaObject(MultimediaObject $mmobj, $tagId, $executeFlush = true)
 {
     $removeTags = array();
     $tag = $this->repository->find($tagId);
     if (!$tag) {
         throw new \Exception("Tag with id " . $tagId . " not found.");
     }
     do {
         $children = $tag->getChildren();
         if (!$mmobj->containsAnyTag($children->toArray())) {
             $removeTags[] = $tag;
             $removed = $mmobj->removeTag($tag);
             if ($removed && !$mmobj->isPrototype()) {
                 $tag->decreaseNumberMultimediaObjects();
             }
             $this->dm->persist($tag);
         } else {
             break;
         }
     } while ($tag = $tag->getParent());
     $this->dm->persist($mmobj);
     if ($executeFlush) {
         $this->dm->flush();
     }
     return $removeTags;
 }
 private function logView($when, MultimediaObject $multimediaObject, Track $track = null)
 {
     $log = new ViewsLog('/', '8.8.8.8', 'test', '', $multimediaObject->getId(), null);
     $log->setDate($when);
     $this->dm->persist($log);
     $this->dm->flush();
     return $log;
 }
示例#5
0
 /**
  * Down Link in Multimedia Object
  *
  * @param MultimediaObject $multimediaObject
  * @param string $linkId
  * @return MultimediaObject
  */
 public function downLinkInMultimediaObject(MultimediaObject $multimediaObject, $linkId)
 {
     $multimediaObject->downLinkById($linkId);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     // NOTE Workaround to fix embedded documents modifications
     $this->dm->clear(get_class($multimediaObject));
     return $this->dm->find('PumukitSchemaBundle:MultimediaObject', $multimediaObject->getId());
 }
示例#6
0
 /**
  * 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);
 }
 /**
  * Remove Pic from Multimedia Object
  */
 public function removePicFromMultimediaObject(MultimediaObject $multimediaObject, $picId)
 {
     $pic = $multimediaObject->getPicById($picId);
     $picPath = $pic->getPath();
     $multimediaObject->removePicById($picId);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     if ($this->forceDeleteOnDisk && $picPath) {
         $this->deleteFileOnDisk($picPath, $multimediaObject);
     }
     return $multimediaObject;
 }
 private function checkMultimediaObject(MultimediaObject $multimediaObject)
 {
     if (!isset($this->profiles[$this->targetProfile])) {
         $this->logger->warning(sprintf('CMAR JobGeneratorListener profile "%s" doesn\'t exist', $this->targetProfile));
         return;
     }
     $sbs = $multimediaObject->getTrackWithTag('sbs');
     $publicTracks = $multimediaObject->getTracksWithTag('profile:' . $this->targetProfile);
     if ($sbs && !$publicTracks) {
         $this->logger->info(sprintf("CMAR JobGeneratorListener creates new job (%s) for SbS in multimedia object %s", $this->targetProfile, $multimediaObject->getId()));
         $jobs[] = $this->jobService->addUniqueJob($sbs->getPath(), $this->targetProfile, 2, $multimediaObject, $sbs->getLanguage());
     }
 }
 /**
  * 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;
 }
 public function preExecute(MultimediaObject $multimediaObject, Request $request)
 {
     if ($multimediaObject->getProperty('iframeable') === true) {
         $this->dispatchViewEvent($multimediaObject);
         return $this->forward('PumukitGeantWebTVBundle:Iframe:index', array('request' => $request, 'multimediaObject' => $multimediaObject));
     } else {
         if ($multimediaObject->getProperty('redirect') === true) {
             $this->dispatchViewEvent($multimediaObject);
             $redirectUrl = $multimediaObject->getProperty('redirect_url');
             if (!$redirectUrl) {
                 throw $this->createNotFoundException();
             }
             return $this->redirect($redirectUrl);
         }
     }
 }
示例#11
0
 /**
  * @ParamConverter("multimediaObject", class="PumukitSchemaBundle:MultimediaObject", options={"id" = "mmId"})
  * @Template
  */
 public function updateAction(MultimediaObject $multimediaObject, Request $request)
 {
     $translator = $this->get('translator');
     $locale = $request->getLocale();
     $link = $multimediaObject->getLinkById($this->getRequest()->get('id'));
     $form = $this->createForm(new LinkType($translator, $locale), $link);
     if (($request->isMethod('PUT') || $request->isMethod('POST')) && $form->bind($request)->isValid()) {
         try {
             $multimediaObject = $this->get('pumukitschema.link')->updateLinkInMultimediaObject($multimediaObject, $link);
         } catch (\Exception $e) {
             $this->get('session')->getFlashBag()->add('error', $e->getMessage());
         }
         return $this->render('PumukitNewAdminBundle:Link:list.html.twig', array('links' => $multimediaObject->getLinks(), 'mmId' => $multimediaObject->getId()));
     }
     return array('link' => $link, 'form' => $form->createView(), 'mm' => $multimediaObject);
 }
 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 genSbs(MultimediaObject $multimediaObject, $opencastUrls = array())
 {
     if (!$this->sbsProfile) {
         return false;
     }
     $tracks = $multimediaObject->getTracks();
     if (!$tracks) {
         return false;
     }
     $track = $tracks[0];
     $path = $this->getPath($track->getUrl());
     $language = $multimediaObject->getProperty('opencastlanguage') ? strtolower($multimediaObject->getProperty('opencastlanguage')) : 'en';
     $vars = $this->defaultVars;
     if ($opencastUrls) {
         $vars += array('ocurls' => $opencastUrls);
     }
     return $this->jobService->addJob($path, $this->sbsProfile, 2, $multimediaObject, $language, array(), $vars);
 }
示例#14
0
 private function createMultimediaObjectAssignedToSeries($title, Series $series)
 {
     $rank = 1;
     $status = MultimediaObject::STATUS_PUBLISHED;
     $record_date = new \DateTime();
     $public_date = new \DateTime();
     $subtitle = 'Subtitle';
     $description = "Description";
     $duration = 0;
     $mm = new MultimediaObject();
     $mm->setStatus($status);
     $mm->setRecordDate($record_date);
     $mm->setPublicDate($public_date);
     $mm->setTitle($title);
     $mm->setSubtitle($subtitle);
     $mm->setDescription($description);
     $mm->setDuration($duration);
     $mm->setSeries($series);
     $this->dm->persist($mm);
     $this->dm->persist($series);
     $this->dm->flush();
     return $mm;
 }
示例#15
0
 public function testAddJob()
 {
     $profiles = $this->getDemoProfiles();
     $pathFile = $this->resourcesDir . 'test.txt';
     $profile = 'MASTER_COPY';
     $priority = 2;
     $language = 'es';
     $description = array('en' => 'test', 'es' => 'prueba');
     $series = new Series();
     $multimediaObject = new MultimediaObject();
     $multimediaObject->setSeries($series);
     $this->dm->persist($series);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     $this->jobService->addJob($pathFile, $profile, $priority, $multimediaObject, $language, $description);
     $this->assertEquals(1, count($this->repo->findAll()));
     $pathFile2 = $this->resourcesDir . 'test2.txt';
     $profile2 = 'MASTER_VIDEO_H264';
     $priority2 = 3;
     $language2 = 'en';
     $description2 = array('en' => 'test2', 'es' => 'prueba2');
     $this->jobService->addJob($pathFile2, $profile2, $priority2, $multimediaObject, $language2, $description2);
     $this->assertEquals(2, count($this->repo->findAll()));
 }
 public function testBroadcast(MultimediaObject $multimediaObject, Request $request)
 {
     if (($broadcast = $multimediaObject->getBroadcast()) && Broadcast::BROADCAST_TYPE_PUB !== $broadcast->getBroadcastTypeId() && (!($broadcastName = $request->headers->get('PHP_AUTH_USER', false)) || $request->headers->get('PHP_AUTH_PW') !== $broadcast->getPasswd() || $broadcastName !== $broadcast->getName())) {
         $seriesUrl = $this->generateUrl('pumukit_webtv_series_index', array('id' => $multimediaObject->getSeries()->getId()), true);
         $redReq = new RedirectResponse($seriesUrl, 302);
         return new Response($redReq->getContent(), 401, array('WWW-Authenticate' => 'Basic realm="Resource not public."'));
     }
     if ($broadcast && Broadcast::BROADCAST_TYPE_PRI === $broadcast->getBroadcastTypeId()) {
         return new Response($this->render("PumukitWebTVBundle:Index:403forbidden.html.twig", array()), 403);
     }
     return true;
 }
 public function testCountInSeries()
 {
     $series1 = new Series();
     $series2 = new Series();
     $this->dm->persist($series1);
     $this->dm->persist($series2);
     $this->dm->flush();
     $mm11 = new MultimediaObject();
     $mm12 = new MultimediaObject();
     $mm13 = new MultimediaObject();
     $mm21 = new MultimediaObject();
     $mm22 = new MultimediaObject();
     $mm23 = new MultimediaObject();
     $mm24 = new MultimediaObject();
     $mm11->setSeries($series1);
     $mm12->setSeries($series1);
     $mm13->setSeries($series1);
     $mm21->setSeries($series2);
     $mm22->setSeries($series2);
     $mm23->setSeries($series2);
     $mm24->setSeries($series2);
     $this->dm->persist($mm11);
     $this->dm->persist($mm12);
     $this->dm->persist($mm13);
     $this->dm->persist($mm21);
     $this->dm->persist($mm22);
     $this->dm->persist($mm23);
     $this->dm->persist($mm24);
     $this->dm->flush();
     $this->assertEquals(3, $this->repo->countInSeries($series1));
     $this->assertEquals(4, $this->repo->countInSeries($series2));
 }
 /**
  * @Template("PumukitNewAdminBundle:Material:list.html.twig")
  */
 public function listAction(MultimediaObject $multimediaObject)
 {
     return array('mmId' => $multimediaObject->getId(), 'materials' => $multimediaObject->getMaterials());
 }
 public function syncThumbnail(MultimediaObject $mmobj, $parsedTerena)
 {
     $url = $parsedTerena['thumbnail'];
     $pics = $mmobj->getPics();
     if (0 === count($pics)) {
         $mmobj = $this->mmsPicService->addPicUrl($mmobj, $url, false);
     } else {
         foreach ($pics as $pic) {
             break;
         }
         //Woraround to get the first element.
         $pic->setUrl($url);
         $this->dm->persist($pic);
     }
 }
示例#20
0
 /**
  * Delete relation of embedded person with role in multimedia object
  *
  * @param  Person           $person
  * @param  Role             $role
  * @param  MultimediaObject $multimediaObject
  * @return boolean          TRUE if this multimedia_object contained the specified person_in_multimedia_object, FALSE otherwise.
  */
 public function deleteRelation(Person $person, Role $role, MultimediaObject $multimediaObject)
 {
     $flag = $multimediaObject->removePersonWithRole($person, $role);
     $role->decreaseNumberPeopleInMultimediaObject();
     $this->dm->persist($multimediaObject);
     $this->dm->persist($role);
     $this->dm->flush();
     return $multimediaObject;
 }
 /**
  * Update relation
  *
  * @Template("PumukitNewAdminBundle:Person:updaterelation.html.twig")
  * @ParamConverter("multimediaObject", class="PumukitSchemaBundle:MultimediaObject", options={"id" = "mmId"})
  * @ParamConverter("role", class="PumukitSchemaBundle:Role", options={"id" = "roleId"})
  */
 public function updateRelationAction(MultimediaObject $multimediaObject, Role $role, Request $request)
 {
     $personService = $this->get('pumukitschema.person');
     $person = $personService->findPersonById($request->get('id'));
     $translator = $this->get('translator');
     $locale = $request->getLocale();
     $form = $this->createForm(new PersonType($translator, $locale), $person);
     if ($request->isMethod('PUT') || $request->isMethod('POST')) {
         if ($form->bind($request)->isValid()) {
             try {
                 $person = $personService->updatePerson($person);
             } catch (\Exception $e) {
                 $this->get('session')->getFlashBag()->add('error', $e->getMessage());
             }
             $template = $multimediaObject->isPrototype() ? '_template' : '';
             return $this->render('PumukitNewAdminBundle:Person:listrelation.html.twig', array('people' => $multimediaObject->getPeopleByRole($role, true), 'role' => $role, 'mm' => $multimediaObject, 'template' => $template));
         } else {
             $errors = $this->get('validator')->validate($person);
             $textStatus = '';
             foreach ($errors as $error) {
                 $textStatus .= $error->getPropertyPath() . ' value ' . $error->getInvalidValue() . ': ' . $error->getMessage() . '. ';
             }
             return new Response($textStatus, 409);
         }
     }
     $template = $multimediaObject->isPrototype() ? '_template' : '';
     return array('person' => $person, 'role' => $role, 'mm' => $multimediaObject, 'template' => $template, 'form' => $form->createView());
 }
 private function createNewMultimediaObjectWithTrack()
 {
     $track = new Track();
     $track->addTag('profile:master');
     $track->setPath('path/to/track.mp4');
     $multimediaObject = new MultimediaObject();
     $multimediaObject->setTitle('MultimediaObject test');
     $multimediaObject->addTrack($track);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $multimediaObject;
 }
 public function testGenerateJobsForAudio()
 {
     $track = new Track();
     $track->addTag("master");
     $track->setPath("path");
     $track->setOnlyAudio(true);
     $mmobj = new MultimediaObject();
     $mmobj->addTrack($track);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGA'));
     $this->assertEquals(array('audio'), $jobs);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGC'));
     $this->assertEquals(array('audio', 'audio2'), $jobs);
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGB'));
     $this->assertEquals(array('audio2'), $jobs);
     //generate a video2 from an audio has no sense.
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGP'));
     $this->assertEquals(array(), $jobs);
     //generate a video from an audio has no sense.
     $jobs = $this->invokeMethod($this->jobGeneratorListener, 'generateJobs', array($mmobj, 'TAGFP'));
     $this->assertEquals(array(), $jobs);
     //generate a video from an audio has no sense.
 }
 /**
  * @Template("PumukitWebTVBundle:MultimediaObject:iframeplayer.html.twig")
  */
 public function indexAction(MultimediaObject $multimediaObject, Request $request)
 {
     $iframeUrl = $multimediaObject->getProperty('iframe_url');
     $this->updateBreadcrumbs($multimediaObject);
     return array('multimediaObject' => $multimediaObject, 'iframe_url' => $iframeUrl);
 }
 public function testDurationInMinutesAndSeconds()
 {
     $duration = 120;
     $duration_in_minutes_and_seconds1 = array('minutes' => 2, 'seconds' => 0);
     $duration_in_minutes_and_seconds2 = array('minutes' => 5, 'seconds' => 30);
     $mm = new MultimediaObject();
     $mm->setDuration($duration);
     $this->assertEquals($duration_in_minutes_and_seconds1, $mm->getDurationInMinutesAndSeconds());
     $mm->setDurationInMinutesAndSeconds($duration_in_minutes_and_seconds2);
     $this->assertEquals($duration_in_minutes_and_seconds2, $mm->getDurationInMinutesAndSeconds());
 }
 /**
  * @Route("/listautocomplete/{mmId}/{roleId}", name="pumukit_ldap_person_listautocomplete")
  * @ParamConverter("multimediaObject", class="PumukitSchemaBundle:MultimediaObject", options={"id" = "mmId"})
  * @ParamConverter("role", class="PumukitSchemaBundle:Role", options={"id" = "roleId"})
  * @Template()
  */
 public function listautocompleteAction(MultimediaObject $multimediaObject, Role $role, Request $request)
 {
     $template = $multimediaObject->isPrototype() ? '_template' : '';
     return array('mm' => $multimediaObject, 'role' => $role, 'template' => $template);
 }
示例#27
0
 public function createTrack(MultimediaObject $multimediaObject, $pathEnd, $profileName, $language = null, $description = array())
 {
     $profile = $this->profileService->getProfile($profileName);
     $track = new Track();
     $track->addTag('profile:' . $profileName);
     if ($profile['master']) {
         $track->addTag('master');
     }
     if ($profile['display']) {
         $track->addTag('display');
     }
     foreach (array_filter(preg_split('/[,\\s]+/', $profile['tags'])) as $tag) {
         $track->addTag(trim($tag));
     }
     if (!empty($description)) {
         $track->setI18nDescription($description);
     }
     $track->setLanguage($language);
     $track->setPath($pathEnd);
     if (isset($profile['streamserver']['url_out'])) {
         $track->setUrl(str_replace(realpath($profile['streamserver']['dir_out']), $profile['streamserver']['url_out'], $pathEnd));
     }
     $this->inspectionService->autocompleteTrack($track);
     $track->setOnlyAudio($track->getWidth() == 0);
     $track->setHide(!$profile['display']);
     $multimediaObject->setDuration($track->getDuration());
     $multimediaObject->addTrack($track);
     $this->dm->persist($multimediaObject);
     $this->dm->flush();
     return $track;
 }
 /**
  * Render iframe
  */
 private function renderIframe(MultimediaObject $multimediaObject, Request $request)
 {
     if ($multimediaObject->getProperty('opencast')) {
         /* $this->incNumView($multimediaObject); */
         /* $this->dispatch($multimediaObject); */
         $userAgent = $this->getRequest()->headers->get('user-agent');
         $mobileDetectorService = $this->get('mobile_detect.mobile_detector');
         $mobileDevice = $mobileDetectorService->isMobile($userAgent) || $mobileDetectorService->isTablet($userAgent);
         $isOldBrowser = $this->getIsOldBrowser($userAgent);
         $track = $multimediaObject->getTrackWithTag('sbs');
         return $this->render("PumukitMoodleBundle:Moodle:opencastiframe.html.twig", array("multimediaObject" => $multimediaObject, "track" => $track, "is_old_browser" => $isOldBrowser, "mobile_device" => $mobileDevice));
     } else {
         $track = $request->query->has('track_id') ? $multimediaObject->getTrackById($request->query->get('track_id')) : $multimediaObject->getFilteredTrackWithTags(array('display'));
     }
     if (!$track) {
         throw $this->createNotFoundException();
     }
     //$this->incNumView($multimediaObject, $track);
     //$this->dispatch($multimediaObject, $track);
     return $this->render("PumukitMoodleBundle:Moodle:iframe.html.twig", array('autostart' => $request->query->get('autostart', 'false'), 'intro' => false, 'multimediaObject' => $multimediaObject, 'track' => $track));
 }
 /**
  * Find similar multimedia objects to a given one
  * with same tags, from different series,
  * broadcast public, status normal,
  * maximum 20 and random
  *
  * @param MultimediaObject $multimediaObject
  * @param array $tags
  * @return ArrayCollection
  */
 public function findRelatedMultimediaObjects(MultimediaObject $multimediaObject)
 {
     $qb = $this->createQueryBuilder()->field('_id')->notEqual($multimediaObject->getId())->field('series')->notEqual($multimediaObject->getSeries()->getId())->field('status')->equals(MultimediaObject::STATUS_PUBLISHED);
     // Broadcast public
     $broadcastRepo = $this->dm->getRepository('PumukitSchemaBundle:Broadcast');
     $broadcast = $broadcastRepo->findPublicBroadcast();
     $qb->field('broadcast')->references($broadcast);
     // Includes PUCHWEBTV code
     $tagRepo = $this->dm->getRepository('PumukitSchemaBundle:Tag');
     $unescoTag = $tagRepo->findOneByCod('UNESCO');
     $codes = array();
     foreach ($multimediaObject->getTags() as $tag) {
         if ($unescoTag) {
             if ($tag->isDescendantOf($unescoTag)) {
                 $codes[] = $tag->getCod();
             }
         }
     }
     $qb->field('tags.cod')->in($codes);
     // Limit 20 and random order
     $qb->limit(20)->sort('rank', mt_rand(0, 1) ? 1 : -1);
     $aux = $qb->getQuery()->execute();
     return $aux;
 }
示例#30
0
 /**
  * @Route("/mm/{id}", methods="GET", name="pumukit_encoder_mm")
  */
 public function multimediaObjectAction(MultimediaObject $multimediaObject, Request $request)
 {
     return $this->redirect($this->generateUrl('pumukitnewadmin_mms_index', array('id' => $multimediaObject->getSeries()->getId(), 'mmid' => $multimediaObject->getId())));
 }