コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function generate(MediaProviderInterface $provider, MediaInterface $media)
 {
     $backend = $this->backend;
     $id = $this->id;
     $publish = function () use($backend, $media, $id) {
         $backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
     };
     // BC compatibility for missing EventDispatcher
     if (null === $this->dispatcher) {
         trigger_error('Since version 2.3.3, passing an empty parameter in argument 4 for __construct() in ' . __CLASS__ . ' is deprecated and the workaround for it will be removed in 3.0.', E_USER_DEPRECATED);
         $publish();
     } else {
         $this->dispatcher->addListener('kernel.finish_request', $publish);
     }
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function updateMetadata(MediaInterface $media, $force = false)
 {
     $base = '//config.playwire.com/%d/videos/v2/%d/zeus.json';
     $ids = explode('|', $media->getProviderReference());
     $url = sprintf($base, $ids[0], $ids[1]);
     try {
         $metadata = $this->getMetadata($media, $url);
     } catch (\RuntimeException $e) {
         $media->setEnabled(false);
         $media->setProviderStatus(MediaInterface::STATUS_ERROR);
         return;
     }
     $media->setContentType($metadata['type']);
     $metadata['thumbnail_url'] = $metadata['content']['poster'];
     $imgsize = getimagesize($metadata['thumbnail_url']);
     $media->setWidth($imgsize[0]);
     $media->setHeight($imgsize[1]);
     $media->setProviderMetadata($metadata);
     if ($force) {
         $media->setName($metadata['settings']['title']);
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array())
 {
     return new RedirectResponse(sprintf('http://vimeo.com/%s', $media->getProviderReference()), 302, $headers);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function generate(MediaProviderInterface $provider, MediaInterface $media)
 {
     $this->backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $this->id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function updateMetadata(MediaInterface $media, $force = false)
 {
     //http://api.soundcloud.com/resolve?url=http://soundcloud.com/matas/hobnotropic&client_id=656c5a7c166b49062f31fbf24eb13fcd
     /* $url = sprintf('http://videos.sapo.pt/oembed?url=http://videos.sapo.pt/%s&format=json', $media->getProviderReference()); */
     /* $url = sprintf('http://api.soundcloud.com/resolve?url=%s', $media->getProviderReference()); */
     /* $url = sprintf('http://soundcloud.com/oembed?url=%s&format=json&client_id=%s', $media->getProviderReference(), '656c5a7c166b49062f31fbf24eb13fcd'); */
     $url = sprintf('http://soundcloud.com/oembed?url=%s&format=json', $media->getProviderReference());
     try {
         $metadata = $this->getMetadata($media, $url);
         /* d($metadata); */
         /* $metadata_thumbnail = $this->getMetadataThumbnail($media); */
         /* $metadata = array_merge($metadata, $metadata_thumbnail); */
     } catch (\RuntimeException $e) {
         $media->setEnabled(false);
         $media->setProviderStatus(MediaInterface::STATUS_ERROR);
         return;
     }
     $media->setProviderMetadata($metadata);
     if ($force) {
         $media->setName($metadata['title']);
         $media->setAuthorName($metadata['author_name']);
     }
     $media->setHeight($metadata['height']);
     $media->setWidth($metadata['width']);
 }